CentOS安装MySQL5.6

 

1、下载

wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.46-linux-glibc2.12-x86_64.tar.gz

2、卸载老版本MySQL

find / -name mysql
rm -rf xxx

3、解压程序包

将MySQL安装在/usr/lcoal/mysql

tar -zxvf mysql-5.6.46-linux-glibc2.12-x86_64.tar.gz

mv mysql-5.6.46-linux-glibc2.12-x86_64 /usr/local/mysql

4、添加MySQL用户、组

groupadd mysql
useradd -r -g mysql mysql

5、建立数据库存在文件夹

比如 /hdd/data/mysql

并配置权限:

chown -R mysql:mysql /hdd/data/mysql
chmod -R 777 /hdd/data/mysql

6、更改mysql 路径权限

cd /usr/local/mysql
chown -R mysql:mysql ./

7、安装

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

(注意:yum install autoconf libaio libaio-devel)


8、拷贝、配置文件

cp support-files/my-default.cnf /etc/my.cnf

我的配置:

[client]
port=3306
socket=/hdd/data/mysql/mysql.sock
default-character-set=utf8

[mysqld]
port=3306
datadir=/hdd/data/mysql
socket=/hdd/data/mysql/mysql.sock
character-set-server=utf8 
collation-server=utf8_general_ci 
lower_case_table_names=1

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

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

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
[mysql.server]
user=mysql
basedir=/usr/local/mysql

9、更改密码

先启动数据库:

./support-files/mysql.server start

设置密码:

./bin/mysqladmin -u root -h localhost.localdomain password 'your_password'

然后可以登录:

./bin/mysql -h 127.0.0.1 -u root -p your_password

设置root 远程登录

mysql> use mysql;
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'your_password' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;

10、设置环境变量

在~/.bash_profile中添加

export PATH=$PATH:/usr/local/mysql/bin

11、加入service系统服务

cp support-files/mysql.server /etc/init.d/mysql
chkconfig --add mysql
chkconfig mysql on
service mysql restart
service mysql status

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值