The environment
- Linux/Ubuntu20.04 LTS
- Mysql – the client – core – 8.0
- The mysql server – 8.0 (8.0.23-0 ubuntu0. 20.04.1)
process
- Open the terminal and check to see if MySQL is installed
lauiji@lauiji-IdeaPad-15sIML-2020:~$ mysql Command 'mysql' not found, but can be installed with: Sudo apt install mysql-client-core 8.0 # version 8.0.23-0ubuntu0.20.04.1, sudo apt install mysql-client-core 8.0 # version 8.0.23-0ubuntu0.20.04.1, Or sudo apt install mariadb-client-core-10.3 # version 1:10.3.25-0ubuntu.20.04.1
- Follow the instructions to install it
Lauiji @ lauiji - siml IdeaPad - 15-2020: ~ $sudo apt install mysql - the client - core - get 8.0:1 http://cn.archive.ubuntu.com/ubuntu Amd64 8.0.23-0ubuntu.20.04.1 [42KB] is setting up mysql-client-core-8.0, which can be used to fix the date-updates (8.0.23-0 ubuntu0. 20.04.1)... Processing trigger for man-db (2.9.1-1)...
- To view running service $systemctl status mysql
lauiji@lauiji-IdeaPad-15sIML-2020:~$ systemctl status mysql
Unit mysql.service could not be found.
- Installation services
Sudo apt-get update sudo apt-get install mysql-server sudo apt-get update sudo apt-get install mysql-server
lauiji@lauiji-IdeaPad-15sIML-2020:~$ sudo apt-get install mysql-server update-alternatives: Use the/var/lib/mecab/dic/ipadic - utf8 in automatic mode provides the/var/lib/mecab dic/debian (mecab - dictionary) are set the mysql server - 8.0 (8.0.23-0 ubuntu0. 20.04.1)... update-alternatives: Removed the options (if) in /etc/mysql/mysql.cnf (my.cnf) Renaming removed key_buffer and myISAM-recover options (if) present) mysqld will log errors to /var/log/mysql/error.log mysqld is running as pid 19429 Created symlink The/etc/systemd/system/multi - user. Target. Wants/mysql service - > / lib/systemd/system/mysql. Service.
The installation is complete!
- View running services
lauiji@lauiji-IdeaPad-15sIML-2020:~$systemctl status MySQL ● MySQL. Service-MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset:> Active: active (running) since Sat 2021-07-03 10:48:52 CST; 24h ago Process: 947 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=ex> Main PID: 991 (mysqld) Status: "Server is operational" : 38 (Limit: 13995) Memory: 402.8M CGroup: Operational / system. Slice/mysql service └ ─ 991 / usr/sbin/mysqld
- How do I log in to the database after installation? Password for what?
Just installed the database has no password, the password is empty, directly enter, log in to the database to change the password
lauiji@lauiji-IdeaPad-15sIML-2020:/etc/mysql$ sudo mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 8.0.23-0Ubuntu 0.20.04.1 (Ubuntu) Copyright (C) 2000, 2021, Oracle and/or its affiliates. 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> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + 4 rows in the set (0.01 SEC)
$sudo cat /etc/mysql/debian.cnf = $sudo cat /etc/mysql/debian.cnf = $sudo cat /etc/mysql/debian.cnf = $sudo cat /etc/mysql/debian.cnf = $sudo cat /etc/mysql/debian.cnf = $sudo cat /etc/mysql/debian.cnf
mysql> select User, Host from mysql.user; +------------------+-----------+ | User | Host | +------------------+-----------+ | debian-sys-maint | localhost | | mysql.infoschema | localhost | | mysql.session | localhost | | mysql.sys | localhost | | root | localhost | + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- -- -- -- - + 5 rows in the set (0.00 SEC)
- Set the password
Set your root login password, for example 123456
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
Query OK, 0 rows affected (0.00 sec)
- Refresh the permissions
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
- Log in again with your new password
mysql> quit;
Bye
lauiji@lauiji-IdeaPad-15sIML-2020:/etc/mysql$ mysql -u root -p
Enter password:
Note: The MySQL8.0 version has changed the way the root account is authorized. The default is AUTH_SOCKET. This means that all users connected to localhost need to be authenticated through the UNIX socket file, instead of providing a password.
- The difference between the initial password of mysql5.7 and mysql8.0 installed in Linux environment
MySQL5.7 and 8.0 initial passwords are not the same after Linux installation.
MySQL5.7 Initial Password
Linux install MySQL5.7, Mysql > create password for 'root' mysql > create password for 'root' mysql > create password for 'root'; $ grep 'temporary password' /var/log/mysqld.log
MySQL8.0 Initial Password
$mysql-u root -p = $mysql-u root -p = $mysql-u root -p = $mysql-u root -p = $mysql-u root -p = $mysql-u root -p = $mysql-u root -p = $mysql-u root -p = $mysql-u root -p
In the rainy season, eat the rainbow