CentOS中文网

Centos 6.5下安装MySQL 5.6

CentOS中文网 https://www.centos.net.cn 2017-03-17 01:15 出处:网络 编辑:@iCMS
1.下载Linux对应的RPM包http://dev.mysql.com/downloads/mysql/5.6.htmlwgethttp://cdn.mysql.com//Downloads/MySQL-5.6/MySQL-5.6.33-1.el6.x86_64.rpm-bundle.tar112.解压tar包

1.下载Linux对应的RPM包

http://dev.mysql.com/downloads/mysql/5.6.htmlwget http://cdn.mysql.com//Downloads/MySQL-5.6/MySQL-5.6.33-1.el6.x86_64.rpm-bundle.tar11

2.解压tar包

tar -xvf MySQL-5.6.33-1.el6.x86_64.rpm-bundle.tar

1

1

3.安装MySQL

rpm -ivh MySQL-server-5.6.33-1.el6.x86_64.rpm

rpm -ivh MySQL-client-5.6.33-1.el6.x86_64.rpm

rpm -ivh MySQL-devel-5.6.33-1.el6.x86_64.rpm

1

2

3

1

2

3

如果出现:

error: Failed dependencies:

libaio.so.1()(64bit) is needed by MySQL-server-5.6.33-1.el6.x86_64

libaio.so.1(LIBAIO_0.1)(64bit) is needed by MySQL-server-5.6.33-1.el6.x86_64

libaio.so.1(LIBAIO_0.4)(64bit) is needed by MySQL-server-5.6.33-1.el6.x86_64

1

2

3

4

1

2

3

4

下载libaio

yum install libaio

1

1

如果出现:

error: Failed dependencies:

libnuma.so.1()(64bit) is needed by MySQL-server-5.6.33-1.el6.x86_64

libnuma.so.1(libnuma_1.1)(64bit) is needed by MySQL-server-5.6.33-1.el6.x86_64

libnuma.so.1(libnuma_1.2)(64bit) is needed by MySQL-server-5.6.33-1.el6.x86_64

1

2

3

4

1

2

3

4

下载numactl

yum install numactl

1

1

4.初始化MySQL及设置密码

/usr/bin/mysql_install_db

service mysql start

1

2

1

2

如果启动失败可能是数据块所在目录没有权限

cat /root/.mysql_secret #查看root账号密码

mysql> SET PASSWORD = PASSWORD('123456');

mysql> exit

1

2

3

1

2

3

如果.mysql_secret文件不存在,先停止MySQL进入安全模式设置密码

service mysql stop

mysqld_safe --skip-grant-tables&

mysql -u root mysql

mysql> UPDATE user SET password=PASSWORD("new password") WHERE user='root';

mysql> FLUSH PRIVILEGES;

1

2

3

4

5

1

2

3

4

5

5.允许远程登陆

mysql> use mysql;

mysql> select host,user,password from user;

mysql> update user set host='%' where user='root' and host='localhost';

mysql> flush privileges;

mysql> exit

1

2

3

4

5

1

2

3

4

5

6.设置开机自启动

chkconfig mysql on

chkconfig --list | grep mysql

mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off

1

2

3

1

2

3

7.MySQL的默认安装位置

/var/lib/mysql/ #数据库目录

/usr/share/mysql #配置文件目录

/usr/bin #相关命令目录

/etc/init.d/mysql #启动脚本

1

2

3

4

1

2

3

4

8.常用命令

1.使用客户端工具连接到数据库

mysql -u root -p

1

1

2.查看MySQL服务器中包含那些数据库

mysql>SHOW DATABASES;

1

1

3.查看数据库中的数据表信息

mysql>SHOW TABLES;

1

1

4.切换数据库

mysql>USE mysql;

1

1

5.创建新的数据库

mysql>CREATE DATABASE 数据库名字;

1

1

6.创建新的数据表

mysql>CREATE TABLE 表名 (字段定义)

1

1

7.删除一个数据表

mysql>DROP TABLE 数据库名.表名;

1

1

8.删除一个数据库

mysql>DROP DATABASE 数据库名

1

1

9.备份整个数据库

mysqldump -u root -p auth > mysql-auth.sql

1

1

10.备份数据库MYSQL中的user表

mysqldump -u root -p mysql user > mysql.host-user.sql

1

1

11.备份MYSQL服务器中所有数据库

mysqldump -u root -p -all-databases > mysql-all.sql

1

1

12.恢复数据库

mysql -u root -p [数据库名]< mysql-all.sql

1

1

13.授予用户权限

GRANT 权限列表 ON 数据库名.表名 TO 用户名@来源地址 [IDENTIFIED BY '密码']

GRANT SELECT ON mysql.user TO daxiong@'localhost' IDENTIFIED BY'123456';

1

精彩评论

暂无评论...
验证码 换一张
取 消