Linux-centos-64bit install MySQL

1. Download mysql installation package to / usr/local/soft

[root@VM_0_9_centos ~]# cd /usr/local/soft
[root@VM_0_9_centos soft]# wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz

2. Installation dependent environment

[root@VM_0_9_centos soft]# yum -y install perl perl-devel autoconf libaio

3. Unzip the installation package

[root@VM_0_9_centos soft]# tar zxvf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz

4. Move the installation package to / usr/local, and change the folder name to mysql.

[root@VM_0_9_centos soft]# mv mysql-5.6.33-linux-glibc2.5-x86_64 /usr/local/mysql

5. Add system mysql group and mysql user

[root@VM_0_9_centos mysql]# groupadd mysql
[root@VM_0_9_centos mysql]# useradd -r -g mysql -s /bin/false mysql

6. Enter / usr/local/mysql to change the directory owner to mysql user.

[root@VM_0_9_centos mysql]# chown -R mysql:mysql ./

7. Installation

[root@VM_0_9_centos mysql]# ./scripts/mysql_install_db --user=mysql

8. Change the current directory owner to root

[root@VM_0_9_centos mysql]# chown -R root:root ./

9. Modify the current data directory owner as mysql user

[root@VM_0_9_centos mysql]# chown -R mysql:mysql ./data

10. Add mysql service to start from the start

[root@VM_0_9_centos mysql]# cp support-files/mysql.server /etc/init.d/mysql
1.Give executable permission
[root@VM_0_9_centos mysql]# chmod +x /etc/init.d/mysql
2.Add service
[root@VM_0_9_centos mysql]# chkconfig --add mysql
3.Show service list
[root@VM_0_9_centos mysql]# chkconfig --list

11. Start mysql service

1.Create missing folder
[root@VM_0_9_centos mysql]# mkdir /var/log/mariadb
2.start-up mysql service
[root@VM_0_9_centos mysql]# service mysql start

12. Add soft connection

[root@VM_0_9_centos mysql]# ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
[root@VM_0_9_centos mysql]# ln -s /usr/local/mysql/bin/mysqldump /usr/local/bin/mysqldump

Solve ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2),Establish a soft connection:
[root@VM_0_9_centos mysql]# ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

13. Configure my.ini to open / etc/my.cnf

[root@VM_0_9_centos mysql]# vim /etc/my.cnf

1.stay[mysqld]Add any line after“ skip-grant-tables"
2.stay[mysqld]Add the following two sentences above
[client] 
default-character-set=utf8
3.stay[mysqld]Add the following words at the bottom
default-storage-engine=INNODB 
character-set-server=utf8 
collation-server=utf8_general_ci
  

14. Save / etc/my.cnf and restart mysql server

[root@VM_0_9_centos mysql]# service mysql restart

15. Change the root login password

[root@VM_0_9_centos mysql]# mysql
  

 


Keywords: Windows MySQL Linux yum MariaDB

Added by nyi8083 on Sun, 20 Oct 2019 20:17:09 +0300