Installing mysql under linux

Keywords: MySQL shell MariaDB yum

Download mysql

Refer to official information

1. This version of mysql needs to rely on libaio library. If not, you can download it using yum

shell> yum search libaio  
shell> yum install libaio 

2. Create mysql users and groups

shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql

3.mysql.server reads / user/local/mysql by default, so the file is extracted to / user/local by default

shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz -C /usr/local
shell> mv /usr/local/mysql-VERSION-OS.tar.gz /usr/local/mysql   Order for mysql

Mysql.server in / MySQL / support files / mysql.server

4. configuration

hell> mkdir mysql-files
shell> chown mysql:mysql mysql-files
shell> chmod 750 mysql-files
shell> bin/mysqld --initialize --user=mysql
shell> bin/mysql_ssl_rsa_setup
shell> bin/mysqld_safe --user=mysql &

Note: Step 5: bin/mysqld --initialize --user=mysql will give you the login password, remember to write it down, otherwise you will log in to mysql without knowing the password

5. Start to solve some common problems

shell> /usr/local/mysql/support-files/mysql.server start

//Display error:
1./var/log/mariadb/mariadb.log If it does not exist, you need to create the log file
shell> mkdir /var/log/mariadb
shell> touch /var/log/mariadb/mariadb.log
shell> chown mysql:mysql /var/log/mariadb
shell> chown mysql:mysql /var/log/mariadb/mariadb.log

2.ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (13)
shell> ln -s /var/lib/mysql/mysql.socket  /tmp/mysql.socket

6. login

shell> cp /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysql.server
shell> /etc/init.d/mysql.server start
shell> mysql -u root -p 
Enter password: 

Enter the login password given before. The first time you log in to mysql, you will need to change the password and then operate. Execute the following command to change the new password to root

mysql>alter user 'root'@'localhost' identified by 'root' expire never;

Exit and login again. expire never means that the password never expires

mysql> show databases;
| Database           |
| information_schema |
| mysql              |
| performance_schema |
| sys                |
4 rows in set (0.00 sec)


Posted by djkanebo on Tue, 28 Jan 2020 07:19:35 -0800