mysql5.6在centos6.9上安装

下载

目前官网的版本到了5.7,但是5.7的安装和5.6及之前有较大的变动,所以,这里还是选用5.6的mysql安装。下载的版本是mysql-5.6.37-linux-glibc2.12-x86_64.tar.gz,即5.6mysql版本,服务器操作系统选linux-generic,64位版本。我的操作系统是centos6.9 64位版

安装

//复制安装包到指定位置,解压,准备安装
cd /usr/local
cp /home/mysql-5.6.37-linux-glibc2.12-x86_64.tar.gz .
tar xzvf mysql-5.6.37-linux-glibc2.12-x86_64.tar.gz 
rm mysql-5.6.37-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.6.37-linux-glibc2.12-x86_64 mysql

//创建mysql用户
useradd mysql
//设置mysql用户密码:
echo '123456'|passwd --stdin mysql
//设置权限:
cd /usr/local 
chown -R mysql:mysql mysql/
//切换到mysql用户
su - mysql 
cd /usr/local/mysql/scripts/  


//安装:
./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

//安装成功的提示信息,复制在这里,以免后面用到
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

  /usr/local/mysql/bin/mysqladmin -u root password 'new-password'
  /usr/local/mysql/bin/mysqladmin -u root -h nature.dev password 'new-password'

Alternatively you can run:

  /usr/local/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

  cd . ; /usr/local/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

  cd mysql-test ; perl mysql-test-run.pl

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

  http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

WARNING: Found existing config file /usr/local/mysql/my.cnf on the system.
Because this file might be in use, it was not replaced,
but was used in bootstrap (unless you used --defaults-file)
and when you later start the server.
The new default config file was created as /usr/local/mysql/my-new.cnf,
please compare it with your file and take the changes you need.

WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server

//设置mysql服务
cp support-files/mysql.server /etc/init.d/mysqld
//启动mysql
service mysqld start
//5.7的root密码在mysql用户目录的.mysql_secret文件中
//设置root用户密码
/usr/local/mysql/bin/mysqladmin -u root password '123456'

//设置root用户远程登陆权限
/usr/local/mysql/bin/mysql -u root -p
输入密码
下面是mysql内操作脚本:
use mysql;
update user set host='%' where user = 'root' limit 1;
flush privileges;

打完收工,至此,mysql服务可以自动启动,root用户可以远程登陆

异常解决

Installing MySQL system tables…/usr/local/mysql/bin/mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory

yum install numactl.x86_64 -y

Starting MySQL. ERROR! The server quit without updating PID file (/var/run/mysqld/mysqld.pid).

关闭selinux

查看SELinux状态:
1、/usr/sbin/sestatus -v ##如果SELinux status参数为enabled即为开启状态
SELinux status: enabled
2、getenforce ##也可以用这个命令检查
关闭SELinux:
1、临时关闭(不用重启机器):
setenforce 0 ##设置SELinux 成为permissive模式
##setenforce 1 设置SELinux 成为enforcing模式
2、修改配置文件需要重启机器:
修改/etc/selinux/config 文件
将SELINUX=enforcing改为SELINUX=disabled
重启机器即可

更改pid文件目录,及权限

配置文件更改为:

[client]  #本地命令行会使用该配置
socket=/var/lib/mysql/mysql.sock  # 不配置的话会找到/tmp目录下去

[mysqld]
skip-name-resolve  #跳过机器名解析,解决初始化安装访问慢的问题
pid-file=/var/run/mysqld/mysqld.pid
datadir=/usr/local/mysql/data
socket=/var/lib/mysql/mysql.sock
user=mysql
log_error = /usr/local/mysql/error.log

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

调整pid文件目录权限

chown -R mysql:mysql /var/run/mysqld
chmod  755 /var/run/mysqld
mkdir /var/lib/mysql
chown -R mysql:mysql /var/lib/mysql
chmod  755 /var/lib/mysql

FATAL ERROR: please install the following Perl modules before executing /usr/local/mysql/scripts/mysql_install_db

解决方法 :安装autoconf库
命令:yum-y install autoconf //此包安装时会安装Data:Dumper模块

error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

yum install -y libaio

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

征途无悔

发文不易,谢谢认可

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值