linux上部署mysql(记录)
默认linux未安装过mysql,若已安装,则自行解决卸载问题。
传送门:https://www.jianshu.com/p/276d59cbc529
- 将 mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz 解压到 /usr/local文件夹下
tar -zxvf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz /usr/local
- 将解压出来的文件名修改为mysql
mv mysql-5.7.22-linux-glibc2.12-x86_64 mysql
- 在/usr/local/mysql下创建文件夹data
mkdir /usr/local/mysql/data
- 修改权限
chown -R mysql:mysql /usr/local/mysql
chmod -R 755 /usr/local/mysql
- 编译安装并初始化mysql
cd /usr/local/mysql/bin
- 在my.cnf下添加如下配置
vi /etc/my.cnf
[mysqld]
datadir=/usr/local/mysql/data
basedir=/usr/local/mysql
socket=/tmp/mysql.sock
user=mysql
port=3306
character-set-server=utf8
- 启动mysql
/usr/local/mysql/support-files/mysql.server start
- 杀mysql进程,找到相应的进程号kill即可,如50365如mysql的进程号
ps -ef|grep mysql
kill -9 50365
- 添加软连接,并重启mysql服务
ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
service mysql restart
- 设置密码
set password for root@localhost = password("password");
- 开放远程连接,刷新配置
use mysql;
update user set user.Host="%" where user.User="root";
flush privileges;
途中碰到问题需自行解决,呵呵
至此,就可以用本地工具Navicat愉快的连接mysql了。
以上是 linux上部署mysql(记录) 的全部内容, 来源链接: utcz.com/z/533166.html