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

1 下载

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

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

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

点击下载mysql

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_64linux

mkdir /usr/loacl/mysqlsql

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

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    socket

vi /etc/my.cnf测试

修改:spa

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

添加:

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命令。

相关文章
相关标签/搜索