linux下多个mysql5.7.19()安装图⽂教程
初级第⼀次在请看上⼀篇,如果已经会安装了,那么请看这篇linux下安装多个mysql-5.7.19
环境:centos 6.5
1-下载
2-跳过登陆
3-1安装多个数据库需要配置⾃⼰的myf,如果只安装⼀个,系统没有安装过直接这个命令就可以
shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql
shell> cd /usr/local
shell> tar zxvf /path/to/
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> mkdir mysql-files
查看下有没有data⽬录如果没有的话增加个命令(mkdir data)
shell> chmod 750 mysql-files
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> bin/mysql_install_db --user=mysql # MySQL 5.7.5
shell> bin/mysqld --initialize --user=mysql # MySQL 5.7.6 and up
shell> bin/mysql_ssl_rsa_setup # MySQL 5.7.6 and up
shell> chown -R root .
shell> chown -R mysql data mysql-files
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server
安装好了就可以直接跳到登陆步骤5
下⾯说安装多个mysql情况:
3-2安装多个数据库需要安照如下命令:
1-增加配置⽂件 myf (在mysql⽬录下命令touch myf):
下⾯配置⽂件可以直接使⽤粘贴复制进去
然后创建log⽂件 /xcxyz/log/mysql/error.log
[mysqld]
basedir= /usr/local/mysql-5.7.19-3307
datadir = /usr/local/mysql-5.7.19-3307/data
port = 3307
character-set-server=utf8
server_id = 11
#该socket最好指定,不指定的话默认的话是使⽤的默认的socket⽂件⽽且登陆数据库的时候会有我下⾯的问题
socket = /tmp/mysql3307.sock
log-error = /xcxyz/log/mysql/error.log
pid-file = /usr/local/mysql-5.7.19-3307/data/mysql-5.7.19-3307.pid
2-执⾏如下命令
2-1增加⽤户组我的⽤户和组都使⽤的是mysqlosf这个随意
shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql
shell> cd /usr/local
shell> tar zxvf /path/to/
2-2建⽴软连接:
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> mkdir mysql-files
查看下有没有data⽬录如果没有的话增加个命令(mkdir data)
2-3授权当前⽬录:
shell> chmod 750 mysql-files
shell> chown -R mysqlosf .
shell> chgrp -R mysqlosf .
2-4编译
bin/mysqld --defaults-file=/usr/local/full-path-to-mysql-VERSION-OS/myf --initialize --user=mysqlosf
查看⽇志输出:vi /xcxyz/log/mysql/error.log
2017-07-24T03:13:47.933684Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2017-07-24T03:13:49.979892Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-07-24T03:13:50.262941Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-07-24T03:13:50.330756Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 1d702294-701e-11e7-98a1-00163e30bbf6.
2017-07-24T03:13:50.340474Z 0 [Warning] Gtid table is not ready to be used. Table 'id_executed' cannot be opened.
2017-07-24T03:13:50.344419Z 1 [Note] A temporary password is generated for root@localhost: jZpgHhigx5>i(特别重要⼀会初始化密码)
linux安装数据库2-5建⽴密钥
shell> bin/mysql_ssl_rsa_setup --defaults-file=/usr/local/mysql-5.7.19-3307/myf
2-6重新授权分配
shell> chown -R root .
shell> chown -R mysql data mysql-files
2-7启动后台mysql
bin/mysqld_safe --defaults-file=/usr/local/full-path-to-mysql-VERSION-OS/myf --user=mysqlosf &
Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server
2-8查看mysql是否启动 ps -ef | grep mysql
4登陆mysql修改密码使⽤刚才的临时密码
我这⾥⼜出问题了哈哈,始终登陆不上去
Access denied for user 'root'@'localhost' (using password:YES)解决⽅法最下⾯
如果登陆上去了可以直接使⽤刚才的临时密码登陆并且设置密码
5-登录MySQL之后,要求⽴即修改密码,否则不能进⾏任何操作。执⾏下⾯的命令修改'root'@'localhost'的密码:
SET PASSWORD = PASSWORD('root');
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
flush privileges;
6-为了可以远程登录,增加⼀个'root'@'%'账号:
grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
7-本地测试连接
按照上⾯的办法,继续解压安装mysql-5.7.19-linux-glibc2.5-x86_,并且配置为3308,3309端⼝,就可以安装多个mysql了。
解决⽅案安装好了登陆不上去:
如果像我上⾯⼀样的话
原因是如下红⾊框内的英⽂我的是第⼆个mysql需要指定socket和port,英⽂意思就是说如果你没有指定socket的话那么会选择默认的因为我们安装多个mysql 所以这个必须指定mysql --socket=/tmp/mysql3307.sock --port=3307 -uroot -p
如果这⾥不⼩⼼丢失了密码了或者密码过期了那么可以通过这个⽅式重置密码:
5-重置密码:
5-1关闭进程
kill `cat /usr/local/mysql-5.7.19-3307/data/mysql-5.7.19-3307.pid` 5-2创建⽂件mysql-init
5-2-1⽂件内容
第⼀种内容:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'mysqlosf';
保存内容之后启动
复制代码代码如下:
bin/mysqld_safe --defaults-file=/usr/local/mysql-5.7.19-3307/myf  --init-file=/usr/local/mysql-5.7.19-3307/mysql-init    --user=mysqlosf    &如果上述内容不成功选择第⼆种内容
UPDATE mysql.user
SET authentication_string = PASSWORD('MyNewPass'), password_expired = 'N'
WHERE User = 'root' AND Host = 'localhost';
FLUSH PRIVILEGES;
保存内容之后启动
复制代码代码如下:
bin/mysqld_safe --defaults-file=/usr/local/mysql-5.7.19-3307/myf  --init-file=/usr/local/mysql-5.7.19-3307/mysql-init  --user=mysqlosf    &
精彩专题分享:
以上就是本⽂的全部内容,希望对⼤家的学习有所帮助,也希望⼤家多多⽀持。

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。