编程知识 cdmana.com

Linux installing MySQL

1. Unload the system mariadb
rpm -qa |grep mariadb |xargs rpm -e --nodeps
Be careful : Install default directory /usr/local
2、 decompression mysql The installation files
tar -zxvf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
After decompression, we enter the installation directory to view, as shown in the figure :

3、 Modify directory name :
mv mysql-5.7.24-linux-glibc2.12-x86_64 mysql
After the change of name , As shown in the figure :

4、 Create data storage directory :
cd /usr/local/mysql
mkdir data
5、 establish mysql User groups and mysql user : // establish mysql Folder management users

groupadd mysql
useradd -r -g mysql mysql
passwd mysql The password is set to //root

6、 change mysql The user groups and users of all directories and folders under the directory , And authority
chown -R mysql:mysql /usr/local/mysql
chmod -R 775 /usr/local/mysql

7、vim /etc/my.cnf

[mysqld]
socket=/var/lib/mysql/mysql.sock
basedir=/usr/local/mysql
#  Set up mysql Database data storage directory 
datadir=/usr/local/mysql/data
#  Maximum connections allowed 
max_connections=200
#  The character set used by the server defaults to 8 Bit coded latin1 Character set 
character-set-server=utf8
#  The default storage engine that will be used when creating a new table 
default-storage-engine=INNODB
lower_case_table_names=1
max_allowed_packet=16M
[client]
port=3306
socket=/var/lib/mysql/mysql.sock

8、 Create the directory used in the previous step , And give authority
sudo mkdir /var/lib/mysql
sudo chown -R mysql:mysql /var/lib/mysql
9、 Establish a soft connection

ln -s /usr/local/mysql/bin/mysql  /usr/local/bin
ln -s /usr/local/mysql/bin/mysqladmin  /usr/local/bin
ln -s /usr/local/mysql/bin/mysqld_safe  /usr/local/bin

**10、 Add environment variables **

vim /etc/profile
export MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin
source /etc/profile

11、 Database initialization cd /usr/local/mysql/bin
mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
remarks : Be sure to initialize a full copy of the password for backup .(*)
**
12、 Boot auto start settings
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
chkconfig --add mysql // Add service
chkconfig --list mysql // Check if the addition is successful , Show 6 Success

13、 Service startup
service mysql start
14、 Client login system
mysql -u root -p
15、 Change the initial login password
set password for root@localhost = password('root');
Part of the screenshot operation

So it's installed MySQL 了

版权声明
本文为[Tu diagram]所创,转载请带上原文链接,感谢

Scroll to Top