Install MySQL5.6.34 in a Linux virtual machine

Chapter 1, the use of xshell tools and xftp

1.1) xshell download and installation

①Used to remotely operate the Linux virtual machine system,
download the free version from the official website of the two tools: https://www.xshell.com/zh/

insert image description here
②Click to download, double-click the .exe file to install directly
insert image description here
③Always go to the next step to install directly
insert image description here

1.2) xshell connection

①File—"New Session—"Enter the IP address of the virtual machine—"Connect
insert image description here
②Enter the Linux account to confirm and enter the password
insert image description here
to connect and then you can remotely control the Linux system in xshell
insert image description here

1.3) xftp download installation and connection

same as xshell

Chapter 2, Install MySQL5.6.34 (different versions have different installation methods)

2.1) Turn off the firewall and transfer the MySQL compressed package to the Linux virtual machine

①Permanently close the firewall

systemctl disable firewalld.service

#重启Linux系统让其生效

reboot

② Log in to xftp to transfer MySQL compressed files, and directly drag and drop the files to transfer the local files to the virtual machine /usr/local folder
insert image description here

③Unzip the MySQL compressed file to the /usr/local directory

tar -zxvf mysql-5.6.34-linux-glibc2.5-x86_64.tar.gz -C /usr/local/MySQL

④Rename to mysql

mv mysql-5.6.34-linux-glibc2.5-x86_64 mysql

2.2) Uninstall mariadb, delete my.cnf

①Query the installed mariadb and uninstall mariadb

rpm -qa|grep mariadb

rpm -e --nodeps 文件名

insert image description here
②Delete my.cnf in the etc directory (no can be ignored)

rm /etc/my.cnf

2.3) Create a MySQL user group

① Create a mysql user group

groupadd mysql

②Create a user named mysql and join the mysql user group

useradd -g mysql mysql

2.4) Configure my.cnf

①Copy a copy of my-default.cnf under /usr/local/mysql/support-files to /etc and rename my.cnf

cp ./mysql/support-files/my-default.cnf /etc/my.cnf

②Edit my.cnf in the /etc directory

vi /etc/my.cnf

③Start configuring my.cnf, copy the following code to the last line, save and exit

[mysql] # 设置mysql客户端默认字符集 
default-character-set=utf8 
socket=/var/lib/mysql/mysql.sock
[mysqld] skip-name-resolve
#设置3306端口 
port = 3306 
socket=/var/lib/mysql/mysql.sock 
# 设置mysql的安装目录 
basedir=/usr/local/mysql 
# 设置mysql数据库的数据的存放目录 
datadir=/usr/local/mysql/data 
# 允许最大连接数 
max_connections=200 
# 服务端使用的字符集默认为8比特编码的latin1字符集 
character-set-server=utf8 
# 创建新表时将使用的默认存储引擎 
default-storage-engine=INNODB 
lower_case_table_name=1 
max_allowed_packet=16M

As shown in the picture:
insert image description here

2.5) Modify the current directory owner to mysql user

①Enter the installation mysql software directory

cd /usr/local/mysql

②Change owner

chown -R mysql:mysql ./

③Install the autoconf library

yum -y install autoconf

④ Install the database in the mysql directory

./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/

⑤In the mysql directory, modify the owner of the current data directory to be the mysql user

chown -R mysql:mysql data

⑥ Grant the maximum authority to my.cnf

chmod 777 /etc/my.cnf

⑦Set the boot self-starting service control script in the mysql directory

cp ./support-files/mysql.server  /etc/rc.d/init.d/mysqld

⑧ Increase mysqld service control script execution authority

chmod +x /etc/rc.d/init.d/mysqld

⑨Add mysqld service to system service

chkconfig --add mysqld

⑩ Check whether the mysqld service has taken effect

chkconfig --list mysqld

The successful result is as follows
insert image description here

2.6) Configure environment variables

①Edit the profile file

vi /etc/profile

② Add the mysql bin directory to the PATH environment variable, save and exit

export PATH=$PATH:/usr/local/mysql/bin

③ Refresh resources

source /etc/profile

2.7) Start MySQL to set a password and make a remote connection

① start mysqld

service mysqld start

②Log in to mysql with the root account, there is no password by default, just press Enter

mysql -uroot -p

③Set your own password, here is root

mysql> set password=password("root");

insert image description here
④ Allow remote login

mysql> grant all privileges on *.* to'root' @'%' identified by 'root';
mysql> flush privileges;

⑤Use navicate on windows to try to connect to mysql
insert image description here

Guess you like

Origin blog.csdn.net/baomingshu/article/details/132032255