
上QQ阅读APP看书,第一时间看更新
Starting the MySQL 8.0 server
You can start the server with the following commands:
- Using service:
shell> sudo service mysql start
- Using init.d:
shell> sudo /etc/init.d/mysql start
- If you do not find the startup script (when you are doing binary installation), you can copy from the location where you untarred.
shell> sudo cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
- If your installation includes systemd support:
shell> sudo systemctl start mysqld
- If the systemd support is not there, MySQL can be started using mysqld_safe. mysqld_safe is the launcher script for mysqld that safeguards the mysqld process. If mysqld is killed, mysqld_safe attempts to start the process again:
shell> sudo mysqld_safe --user=mysql &
After start,
- The server is initialized.
- The SSL certificate and key files are generated in the data directory.
- The validate_password plugin is installed and enabled.
- A superuser account, root'@'localhost, is created. A password for the superuser is set and stored in the error log file (not for binary installation). To reveal it, use the following command:
shell> sudo grep "temporary password" /var/log/mysqld.log
2017-12-02T07:23:20.915827Z 5 [Note] A temporary password is generated for root@localhost: bkvotsG:h6jD
You can connect to MySQL using that temporary password.
shell> mysql -u root -pbkvotsG:h6jD
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 8.0.3-rc-log
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
- Change the root password as soon as possible by logging in with the generated temporary password and setting a custom password for the superuser account:
# You will be prompted for a password, enter the one you got from the previous step
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPass4!';
Query OK, 0 rows affected (0.01 sec)
# password should contain at least one Upper case letter, one lowercase letter, one digit, and one special character, and that the total password length is at least 8 characters