Centos7下安装MySql5.6
2018-02-06 16:23
357 查看
一、开始
前往Mysql官网点击打开链接下载mysql 5.6,上传至centos7服务器上/usr/local/(哪个目录看个人习惯)
![](https://img-blog.csdn.net/20180206153734704?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdmludmlz/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
安装前必须删除原来的安装
需要检查 以下文件是否存在,如果存储则要删除之
/etc/my.cnf
/etc/init.d/mysqld
二、下载mysql依赖的库
shell> yum search libaio # search for info
shell> yum install libaio # install library
三、创建mysql
与用户组,-s /bin/false
表示该用户不能登录
shell> groupadd mysql
shell>useradd -r -g mysql
-s /bin/false mysql
四、解压安装包到指定目录
shell> tar zxvf
mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
shell> ln -s
mysql-5.6.39-linux-glibc2.12-x86_64 mysql
shell> cd mysql
五、为mysql用户添加权限
shell> chown -R mysql
./
shell> chgrp -R mysql
./
#创建data目录并添加权限
shell> mkdir -p /data/mysql
shell> chown -R mysql:mysql /data/mysql
六、拷贝配置文件
shell> cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
#修改配置
vi /etc/my.cnf
#添加配置
[mysqld]
basedir=/usr/local/mysql
datadir=/data/mysql
character-set-server=utf8
#拷贝启动文件
shell> cp
/usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
七、初始化 mysql
库
shell>/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
八、添加环境变量
shell> vi /etc/profile
PATH=/usr/local/mysql/bin:$PATH
export PATH
#让刚才的修改生效
shell>source /etc/profile
九、启动数据库
shell> service mysql start
十、其他配置
#开机启动
chkconfig mysql on
#初始化mysql的一些设置
shell> ./usr/local/mysql/bin/mysql_secure_installation
#回车
Enter current password for root (enter for none):
#y,设置mysql的root密码
Set root password?[Y/n] y
#以下都yes
Remove anonymous users?[Y/n] y
Disallow root login remotely?[Y/n] y
Remove test database and access to it?[Y/n] y
Reload privilege tables now?[Y/n] y
ThanksforusingMySQL!
允许远程登陆方法一
1. mysql> use mysql;
2. mysql> select host,user,password from user;
3. mysql> update user set password=password('123456')where user='root';
4. mysql> update user set host='%' where user='root' andhost='localhost';
5. mysql> flush privileges;
允许远程登录方法二
1. mysql>
use mysql;
2. mysql>grant all privileges on *.* to 'root'@'%'identified by '123456' with grant option;
3. mysql>flush privileges;
十一、补充
安装时的一些错误
-bash: ./scripts/mysql_install_db: /usr/bin/perl: bad interpreter:
没有那个文件或目录
解决: yum -yinstall perl perl-devel
Installing MySQL system tables..../bin/mysqld: error while loadingshared libraries: libaio.so.1: cannot open shared object file: No such file ordirectory
解决:yum -y installlibaio-devel
前往Mysql官网点击打开链接下载mysql 5.6,上传至centos7服务器上/usr/local/(哪个目录看个人习惯)
安装前必须删除原来的安装
需要检查 以下文件是否存在,如果存储则要删除之
/etc/my.cnf
/etc/init.d/mysqld
二、下载mysql依赖的库
shell> yum search libaio # search for info
shell> yum install libaio # install library
三、创建mysql
与用户组,-s /bin/false
表示该用户不能登录
shell> groupadd mysql
shell>useradd -r -g mysql
-s /bin/false mysql
四、解压安装包到指定目录
shell> tar zxvf
mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
shell> ln -s
mysql-5.6.39-linux-glibc2.12-x86_64 mysql
shell> cd mysql
五、为mysql用户添加权限
shell> chown -R mysql
./
shell> chgrp -R mysql
./
#创建data目录并添加权限
shell> mkdir -p /data/mysql
shell> chown -R mysql:mysql /data/mysql
六、拷贝配置文件
shell> cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
#修改配置
vi /etc/my.cnf
#添加配置
[mysqld]
basedir=/usr/local/mysql
datadir=/data/mysql
character-set-server=utf8
#拷贝启动文件
shell> cp
/usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
七、初始化 mysql
库
shell>/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
八、添加环境变量
shell> vi /etc/profile
PATH=/usr/local/mysql/bin:$PATH
export PATH
#让刚才的修改生效
shell>source /etc/profile
九、启动数据库
shell> service mysql start
十、其他配置
#开机启动
chkconfig mysql on
#初始化mysql的一些设置
shell> ./usr/local/mysql/bin/mysql_secure_installation
#回车
Enter current password for root (enter for none):
#y,设置mysql的root密码
Set root password?[Y/n] y
#以下都yes
Remove anonymous users?[Y/n] y
Disallow root login remotely?[Y/n] y
Remove test database and access to it?[Y/n] y
Reload privilege tables now?[Y/n] y
ThanksforusingMySQL!
允许远程登陆方法一
1. mysql> use mysql;
2. mysql> select host,user,password from user;
3. mysql> update user set password=password('123456')where user='root';
4. mysql> update user set host='%' where user='root' andhost='localhost';
5. mysql> flush privileges;
允许远程登录方法二
1. mysql>
use mysql;
2. mysql>grant all privileges on *.* to 'root'@'%'identified by '123456' with grant option;
3. mysql>flush privileges;
十一、补充
安装时的一些错误
-bash: ./scripts/mysql_install_db: /usr/bin/perl: bad interpreter:
没有那个文件或目录
解决: yum -yinstall perl perl-devel
Installing MySQL system tables..../bin/mysqld: error while loadingshared libraries: libaio.so.1: cannot open shared object file: No such file ordirectory
解决:yum -y installlibaio-devel
相关文章推荐
- CentOS 7下源码安装MySQL 5.6
- Centos7下完美安装并配置mysql5.6
- Centos7下完美安装并配置mysql5.6
- CentOS7下yum安装mysql5.6
- Centos7下完美安装并配置mysql5.6
- centos7下yum安装mysql5.6
- Centos7下完美安装并配置mysql5.6
- 170419、Centos7下完美安装并配置mysql5.6
- Centos7下完美安装并配置mysql5.6
- CentOS7下源码安装mysql5.6
- CentOS7下安装mysql5.6修改字符集为utf8并开放端口允许远程访问
- CentOS7下MySQL5.6基于二进制包方式安装记录
- CentOS 7下源码安装MySQL 5.6
- 关于centOS7下使用rpm方式安装mysql5.6过程说明
- 阿里云CentOS7下mysql5.6安装问题总结
- CentOS7下yum方式安装mysql5.6
- CentOS 7下安装MySql 5.6 错误 产生冲突
- 实战mysql集群搭建(一)--centos7下二进制安装mysql-5.6
- CentOS7下安装mysql5.6修改字符集为utf8并开放端口允许远程访问
- CentOS 7下源码安装MySQL 5.6