Installing MySQL 5.6 Tutorial under Centos 6.5

  • 2021-07-22 11:46:34
  • OfStack

1. Download the RPM package corresponding to Linux

http://dev.mysql.com/downloads/mysql/5.6.html

wget http://cdn.mysql.com//Downloads/MySQL-5.6/MySQL-5.6.33-1.el6.x86_64.rpm-bundle.tar

2. Unzip the tar packet


tar -xvf MySQL-5.6.33-1.el6.x86_64.rpm-bundle.tar

3. Install MySQL


rpm -ivh MySQL-server-5.6.33-1.el6.x86_64.rpm 
rpm -ivh MySQL-client-5.6.33-1.el6.x86_64.rpm 
rpm -ivh MySQL-devel-5.6.33-1.el6.x86_64.rpm

If:


error: Failed dependencies:
    libaio.so.1()(64bit) is needed by MySQL-server-5.6.33-1.el6.x86_64
    libaio.so.1(LIBAIO_0.1)(64bit) is needed by MySQL-server-5.6.33-1.el6.x86_64
    libaio.so.1(LIBAIO_0.4)(64bit) is needed by MySQL-server-5.6.33-1.el6.x86_64

Download libaio


yum install libaio

If:


error: Failed dependencies:
    libnuma.so.1()(64bit) is needed by MySQL-server-5.6.33-1.el6.x86_64
    libnuma.so.1(libnuma_1.1)(64bit) is needed by MySQL-server-5.6.33-1.el6.x86_64
    libnuma.so.1(libnuma_1.2)(64bit) is needed by MySQL-server-5.6.33-1.el6.x86_64

Download numactl


yum install numactl

4. Initialize MySQL and set password


/usr/bin/mysql_install_db
service mysql start

If startup fails, it may be that the directory where the data block is located does not have


cat /root/.mysql_secret # View root Account password 
mysql> SET PASSWORD = PASSWORD('123456');
mysql> exit

If the. mysql_secret file does not exist, stop MySQL and enter safe mode to set the password


service mysql stop
mysqld_safe --skip-grant-tables&
mysql -u root mysql
mysql> UPDATE user SET password=PASSWORD("new password") WHERE user='root';
mysql> FLUSH PRIVILEGES;

Step 5 Allow remote login


mysql> use mysql;
mysql> select host,user,password from user;
mysql> update user set host='%' where user='root' and host='localhost';
mysql> flush privileges;
mysql> exit

6. Set boot self-startup


rpm -ivh MySQL-server-5.6.33-1.el6.x86_64.rpm 
rpm -ivh MySQL-client-5.6.33-1.el6.x86_64.rpm 
rpm -ivh MySQL-devel-5.6.33-1.el6.x86_64.rpm
0

7. Default installation location of 7. MySQL


/var/lib/mysql/        # Database directory 
/usr/share/mysql       # Configuration file directory 
/usr/bin           # Related command directory 
/etc/init.d/mysql       # Startup script 

8. Common commands

1. Connecting to a database using client tools


mysql -u root -p

2. View which databases are included in the MySQL server


rpm -ivh MySQL-server-5.6.33-1.el6.x86_64.rpm 
rpm -ivh MySQL-client-5.6.33-1.el6.x86_64.rpm 
rpm -ivh MySQL-devel-5.6.33-1.el6.x86_64.rpm
3

3. View table information in the database


rpm -ivh MySQL-server-5.6.33-1.el6.x86_64.rpm 
rpm -ivh MySQL-client-5.6.33-1.el6.x86_64.rpm 
rpm -ivh MySQL-devel-5.6.33-1.el6.x86_64.rpm
4

4. Switch databases


rpm -ivh MySQL-server-5.6.33-1.el6.x86_64.rpm 
rpm -ivh MySQL-client-5.6.33-1.el6.x86_64.rpm 
rpm -ivh MySQL-devel-5.6.33-1.el6.x86_64.rpm
5

5. Create a new database


rpm -ivh MySQL-server-5.6.33-1.el6.x86_64.rpm 
rpm -ivh MySQL-client-5.6.33-1.el6.x86_64.rpm 
rpm -ivh MySQL-devel-5.6.33-1.el6.x86_64.rpm
6

6. Create a new data table


mysql>CREATE TABLE  Table name  ( Field definition )

7. Delete a data table


mysql>DROP TABLE  Database name . Table name ;

8. Delete 1 database


rpm -ivh MySQL-server-5.6.33-1.el6.x86_64.rpm 
rpm -ivh MySQL-client-5.6.33-1.el6.x86_64.rpm 
rpm -ivh MySQL-devel-5.6.33-1.el6.x86_64.rpm
9

9. Back up the entire database


mysqldump -u root -p auth > mysql-auth.sql

10. Back up the user table in the database MYSQL


mysqldump -u root -p mysql user > mysql.host-user.sql

11. Back up all databases in the MYSQL server


mysqldump -u root -p -all-databases > mysql-all.sql

12. Restore the database


mysql -u root -p [ Database name ]< mysql-all.sql

13. Grant user rights


GRANT  Permission list  ON  Database name . Table name  TO  User name @ Source address  [IDENTIFIED BY ' Password ']
GRANT SELECT ON mysql.user TO daxiong@'localhost' IDENTIFIED BY'123456';

Related articles: