Mysql(5.6.35)在Linux(Centos 6.8)上安装

℡╲_俬逩灬. 提交于 2020-03-02 17:03:19

1 下载

下载地址:https://dev.mysql.com/downloads/mysql/5.6.html#downloads

这里我选择5.6.41 Linux-Generic,如下图:

再选择Linux - Generic (glibc 2.5) (x86, 64-bit), Compressed TAR Archive包,根据系统选择32或64位,如下图:

点击下载

2 解压

root用户登录,上传安装包到服务器
cd /opt
rz
解压
tar -xvf mysql-5.6.41-linux-glibc2.12-x86_64.tar
复制解压后的mysql目录
cd mysql-5.6.41-linux-glibc2.12-x86_64

mkdir /usr/loacl/mysql

cp -r ./* /usr/local/mysql

3 添加用户组和用户

添加用户组
groupadd mysql
添加用户mysql到用户组
useradd -g mysql mysql

4 安装

cd /usr/local/mysql
chown -R mysql:mysql ./
./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
cp support-files/mysql.server /etc/init.d/mysql
cp support-files/my-default.cnf /etc/my.cnf    

vi /etc/my.cnf

修改:

basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
port=3306
server_id=1
socket=/tmp/mysql.sock

添加:

character_set_server=utf8

加入环境变量,编辑 /etc/profile,这样可以在任何地方用mysql命令了

export PATH=$PATH:/usr/local/mysql/bin
source /etc/profile

启动mysql
service mysql start

修改root密码

mysqladmin -u root password '123456'

测试连接
mysql -u root -p
关闭mysql
service mysql stop
查看运行状态
service mysql status

开机自启动配置
chkconfig --add mysql
chkconfig --list
chkconfig --level 345 mysql on

允许所有外部链接访问

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
FLUSH PRIVILEGES;

5 注意事项

安装时的一些错误
   -bash: ./scripts/mysql_install_db: /usr/bin/perl: bad interpreter: 没有那个文件或目录
   解决: yum -y install perl perl-devel
  Installing MySQL system tables…./bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
   解决:yum -y install libaio-devel

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

     解决:yum -y install numactl

 

启动时一些错误

    Can't open the mysql.plugin table. Please run mysql_upgrade to create it.

        解决:关闭selinux 在/etc/selinux/config下永久关闭,临时关闭使用setenforce 0命令。

    

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!