CentOS6.9下二进制安装MySQL5.6版本

下载mysql5.6二进制安装包 

添加用户和组

groupadd mysql
useradd -g mysql mysql

上传mysql安装包解压

cd /usr/local
tar -zxvf mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.6.26-linux-glibc2.5-x86_64 mysql
cd /usr/local/mysql
chown -R mysql .
chgrp -R mysql .

开始安装

/usr/local/mysql/scripts/mysql_install_db  --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

复制配置文件

cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf

修改配置文件

[client]
port = 3306
socket = /usr/local/mysql/mysql.sock
default-character-set = utf8
[mysqld]
skip-name-resolve
user = mysql
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
server_id = 10
socket = /usr/local/mysql/mysql.sock
pid-file = /usr/local/mysql/mysql.pid
log-error = /usr/local/mysql/data/mysql.err
log-bin = /usr/local/mysql/data/mysql-bin
character-set-server = utf8

设置系统服务

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

配置环境变量

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

启动mysql

service mysqld start

修改mysql密码

mysqladmin -u root password '123456'

登陆mysql

mysql -uroot -p
[root@localhost /]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.6.42-log MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

配置远程连接

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

flush privileges;

 

posted @ 2018-11-13 14:39  wangzihong  阅读(336)  评论(0编辑  收藏  举报