1 切换目录,下载压缩包
cd /usr/local/
wget https://cdn.mysql.com/archives/mysql-5.6/mysql-5.6.45-linux-glibc2.12-x86_64.tar.gz
2 解压并将文件夹重命名
tar -zxvf mysql-5.6.45-linux-glibc2.12-x86_64.tar.gz
rm -rf mysql-5.6.45-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.6.45-linux-glibc2.12-x86_64/ mysql
3 添加用户组mysql (执行路径为 /usr/local)
groupadd mysql
useradd -r -g mysql mysql
groups mysql
4 增加目录并重新赋予权限
mkdir -p /data/mysql
chown mysql:mysql -R /data/mysql
5 配置my.cnf
vim /etc/my.cnf
内容如下:
[mysqld]
bind-address=0.0.0.0
port=3306
user=mysql
basedir=/usr/local/mysql
datadir=/data/mysql
socket=/tmp/mysql.sock
log-error=/data/mysql/mysql.err
pid-file=/data/mysql/mysql.pid
#character config
character_set_server=utf8mb4
symbolic-links=0
explicit_defaults_for_timestamp=true
6 然后切换到 /usr/local/mysql/bin目录下
cd /usr/local/mysql/bin/
执行初始化命令
./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/ --datadir=/data/mysql/ --user=mysql --initialize
7 将mysql.server 放置到 /etc/init.d/mysql 中
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
8 启动mysql服务
service mysql start
ps -ef|grep mysql
8 修改密码登录mysql
./bin/mysqladmin -u root password '123456'
./bin/mysql -h127.0.0.1 -uroot -p000000
Linux在登录之后 开启远程登录,刷新权限
grant all privileges on *.* to root@'%' identified by '123456';
flush privileges;
9 Mysql设置开机自启
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
问题总结:
1 执行初始化命令的时候 提示如下错误
./mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory
解决办法:
切换到local目录,然后执行
yum install -y libaio
yum -y install numactl
2 执行mysql start的情况下 提示
Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
解决办法:
切换到 mysql目录下,执行
./scripts/mysql_install_db --user=mysql
3 ping 腾讯云服务器能够ping 通,但是 远程连接mysql无法连接
应该是被防火墙给拦截了,可以先在腾讯云控制台 防火墙 修改安全规则 ,开放3306端口
如果还是不行就
先查看防火墙状态
firewall-cmd --state
查看开放的端口
firewall-cmd --list-all
开放3306端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
最后重启防火墙
firewall-cmd --reload