linux如何安装mysql5.7的方法
这篇文章主要为大家展示了“linux如何安装MySQL5.7的方法”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“linux如何安装mysql5.7的方法”这篇文章吧。
创新互联是一家专注于网站设计、成都网站设计与策划设计,安庆网站建设哪家好?创新互联做网站,专注于网站建设十载,网设计领域的专业建站公司;建站业务涵盖:安庆等地区。安庆做网站价格咨询:18982081108
mysql 单节点安装,前查询:https://my.oschina.net/u/3411575/blog/5047890
步骤1:
自行下载mysql5.7
步骤2:
解压:
tar -xvf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
步骤3:
移动解压得到的文件夹,并重命名:
mv mysql-5.7.26-linux-glibc2.12-x86_64 /usr/local/mysql
步骤4:
创建文件夹
/home/mysql/data3306
/home/mysql/data3307
/home/mysql/data3309
步骤5:
编辑/etc/my.cnf
client] port=3306 socket=/tmp/mysql.sock [mysqld_multi] mysqld = /usr/local/mysql/bin/mysqld_safe mysqladmin = /usr/local/mysql/bin/mysqladmin log = /home/mysql/mysqld_multi.log [mysqld] user=mysql basedir = /usr/local/mysql sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION [mysqld3306] mysqld=mysqld mysqladmin=mysqladmin datadir=/home/mysql/data3306/data port=3306 server_id=3306 socket=/tmp/data3306.sock log-output=file slow_query_log = 1 long_query_time = 1 slow_query_log_file = /home/mysql/mysql3306/log/slow.log log-error = /home/mysql/mysql3306/log/error.log binlog_format = mixed log-bin = /home/mysql/mysql3306/log/mysql3306_bin [mysqld3309] mysqld=mysqld mysqladmin=mysqladmin datadir=/home/mysql/data3308/data port=3309 server_id=3309 socket=/tmp/data3309.sock log-output=file slow_query_log = 1 long_query_time = 1 slow_query_log_file = /home/mysql/mysql3309/log/slow.log log-error = /home/mysql/mysql3309/log/error.log binlog_format = mixed log-bin = /home/mysql/mysql3309/log/mysql3309_bin
步骤6:
新建单独实例的初始化配置文件(要与/etc/my.cnf文件配置保持一致) 分别存放在 /home/mysql/data3306 /home/mysql/data3307 /home/mysql/data3309 中
my.cnf(3306.cnf)
[client] port= 3306 socket= /home/mysql/data3306/mysql.sock default-character-set=utf8 [mysqld] user=mysql port=3306 basedir=/usr/local/mysql datadir=/home/mysql/data3306/data server_id=3306 socket=/home/mysql/data3306/mysql.sock log-output=file slow_query_log=1 long_query_time=1 slow_query_log_file=/home/mysql/data3306/log/slow.log symbolic-links=0 log-error=/home/mysql/data3306/log/error.log log-bin=/home/mysql/data3306/log/bin.log pid-file=/home/mysql/data3306/mysql3306.pid binlog_format=mixed lower-case-table_names=1 log-bin-trust-function-creators=1 sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION character-set-server=utf8
my.cnf(3307.cnf)
[client] port= 3307 socket= /home/mysql/data3307/mysql.sock default-character-set=utf8 [mysqld] user=mysql port=3307 basedir=/usr/local/mysql datadir=/home/mysql/data3307/data server_id=3307 socket=/home/mysql/data3307/mysql.sock log-output=file slow_query_log=1 long_query_time=1 slow_query_log_file=/home/mysql/data3307/log/slow.log symbolic-links=0 log-error=/home/mysql/data3307/log/error.log log-bin=/home/mysql/data3307/log/bin.log pid-file=/home/mysql/data3307/mysql3307.pid binlog_format=mixed lower-case-table_names=1 log-bin-trust-function-creators=1 sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION character-set-server=utf8
my.cnf(3309.cnf)
[client] port= 3309 socket= /home/mysql/data3309/mysql.sock default-character-set=utf8 [mysqld] user=mysql port=3309 basedir=/usr/local/mysql datadir=/home/mysql/data3309/data server_id=3309 socket=/home/mysql/data3309/mysql.sock log-output=file slow_query_log=1 long_query_time=1 slow_query_log_file=/home/mysql/data3309/log/slow.log symbolic-links=0 log-error=/home/mysql/data3309/log/error.log log-bin=/home/mysql/data3309/log/bin.log pid-file=/home/mysql/data3309/mysql3309.pid binlog_format=mixed lower-case-table_names=1 log-bin-trust-function-creators=1 sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION character-set-server=utf8
步骤6-1:
创建文件夹/home/mysql/data330{6,7,9}/log并创建文件图中4个文件
步骤7:
开始赋权限
chown mysql:mysql -R /home/mysql/ chown mysql:mysql -R /usr/local/mysql
步骤8:
初始化数据库, 这里生成mysql.sock文件 :
/usr/local/mysql/bin/mysqld --defaults-file=/home/mysql/data3306/my.cnf --initialize --basedir=/usr/local/mysql/ --datadir=/home/mysql/data3306/data /usr/local/mysql/bin/mysqld_safe --defaults-file=/home/mysql/data3306/my.cnf & /usr/local/mysql/bin/mysqld --defaults-file=/home/mysql/data3307/my.cnf --initialize --basedir=/usr/local/mysql/ --datadir=/home/mysql/data3307/data /usr/local/mysql/bin/mysqld_safe --defaults-file=/home/mysql/data3307/my.cnf & /usr/local/mysql/bin/mysqld --defaults-file=/home/mysql/data3309/my.cnf --initialize --basedir=/usr/local/mysql/ --datadir=/home/mysql/data3309/data /usr/local/mysql/bin/mysqld_safe --defaults-file=/home/mysql/data3309/my.cnf &
这里会生成默认密码,可以去error.log中看
//-----------------------------------------以上-数据库初始化完毕----
步骤9:
命令行中运行各个mysql实例:
/usr/local/mysql/bin/mysql -uroot -p -S /home/mysql/data3306/mysql.sock
输入初始化密码:
修改密码:
SET PASSWORD = PASSWORD('123456'); ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER; FLUSH PRIVILEGES;
设置navicat可连接:
use mysql #访问mysql库 update user set host = '%' where user = 'root'; #使root能再任何host访问 FLUSH PRIVILEGES; #刷新
步骤10:
navicat连接数据库
停止节点:
查看进程号 :ps aux | grep mysql
以上是“linux如何安装mysql5.7的方法”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联行业资讯频道!
分享文章:linux如何安装mysql5.7的方法
分享URL:http://cdiso.cn/article/jcedep.html