安装MYSQL

安装MYSQL

查看当前安装的mariadb包:

[root@bogon 桌面]# rpm -qa | grep mariadb

将它们统统强制性卸载掉:

[root@bogon 桌面]# rpm -e --nodeps mariadb-libs-5.5.35-3.el7.x86_64

[root@bogon 桌面]# rpm -e --nodeps mariadb-5.5.35-3.el7.x86_64

[root@bogon 桌面]# rpm -e --nodepsmariadb-server-5.5.35-3.el7.x86_64

 

[root@promote mysql]# rpm -qa|grep -i mysql

MySQL-devel-advanced-5.6.22-1.el7.x86_64

MySQL-server-advanced-5.6.22-1.el7.x86_64

MySQL-client-advanced-5.6.22-1.el7.x86_64

[root@promote mysql]# rpm -evMySQL-devel-advanced-5.6.22-1.el7.x86_64

软件包准备中...

[root@promote mysql]# rpm -evMySQL-client-advanced-5.6.22-1.el7.x86_64

软件包准备中...

MySQL-client-advanced-5.6.22-1.el7.x86_64

[root@promote mysql]# rpm -evMySQL-server-advanced-5.6.22-1.el7.x86_64

软件包准备中...

MySQL-server-advanced-5.6.22-1.el7.x86_64

[root@promote mysql]# rpm -qa|grep -i mysql

[root@promote mysql]#

删除mysql目录

[root@promote mysql]# cd

[root@promote ~]# find / -name mysql

/usr/lib64/mysql

/var/lib/mysql

/var/lib/mysql/mysql

[root@promote ~]#

[root@promote ~]# rm -rf /usr/lib64/mysql

[root@promote ~]# rm -rf /var/lib/mysql/

 

 

 

安装

[root@promotemysql]# rpm -ivh MySQL-devel-advanced-5.6.22-1.el7.x86_64.rpm

准备中...         #################################[100%]

正在升级/安装...

  1:MySQL-devel-advanced-5.6.22-1.el7#################################[root@promote mysql]# rpm -ivh MySQL-server-advanced-5.6.22-1.el7.x86_64.rpm

准备中...                         ################################# [100%]

正在升级/安装...

  1:MySQL-server-advanced-5.6.22-1.el#################################[100%]

2015-05-27 12:07:49 0 [Warning] TIMESTAMP withimplicit DEFAULT value is deprecated. Please use--explicit_defaults_for_timestamp server option (see documentation for moredetails).

2015-05-27 12:07:49 3273 [Note] InnoDB: Using atomicsto ref count buffer pool pages

2015-05-27 12:07:49 3273 [Note] InnoDB: The InnoDBmemory heap is disabled

2015-05-27 12:07:49 3273 [Note] InnoDB: Mutexes andrw_locks use GCC atomic builtins

2015-05-27 12:07:49 3273 [Note] InnoDB: Memory barrieris not used

2015-05-27 12:07:49 3273 [Note] InnoDB: Compressedtables use zlib 1.2.3

2015-05-27 12:07:49 3273 [Note] InnoDB: Using Linuxnative AIO

2015-05-27 12:07:49 3273 [Note] InnoDB: Using CPUcrc32 instructions

2015-05-27 12:07:49 3273 [Note] InnoDB: Initializingbuffer pool, size = 128.0M

2015-05-27 12:07:49 3273 [Note] InnoDB: Completedinitialization of buffer pool

2015-05-27 12:07:49 3273 [Note] InnoDB: The firstspecified data file ./ibdata1 did not exist: a new database to be created!

2015-05-27 12:07:49 3273 [Note] InnoDB: Setting file./ibdata1 size to 12 MB

2015-05-27 12:07:49 3273 [Note] InnoDB: Databasephysically writes the file full: wait...

2015-05-27 12:07:50 3273 [Note] InnoDB: Setting logfile ./ib_logfile101 size to 48 MB

2015-05-27 12:07:50 3273 [Note] InnoDB: Setting log file./ib_logfile1 size to 48 MB

2015-05-27 12:07:51 3273 [Note] InnoDB: Renaming logfile ./ib_logfile101 to ./ib_logfile0

2015-05-27 12:07:51 3273 [Warning] InnoDB: New logfiles created, LSN=45781

2015-05-27 12:07:51 3273 [Note] InnoDB: Doublewritebuffer not found: creating new

2015-05-27 12:07:52 3273 [Note] InnoDB: Doublewritebuffer created

2015-05-27 12:07:52 3273 [Note] InnoDB: 128 rollbacksegment(s) are active.

2015-05-27 12:07:52 3273 [Warning] InnoDB: Creatingforeign key constraint system tables.

2015-05-27 12:07:52 3273 [Note] InnoDB: Foreign keyconstraint system tables created

2015-05-27 12:07:52 3273 [Note] InnoDB: Creatingtablespace and datafile system tables.

2015-05-27 12:07:52 3273 [Note] InnoDB: Tablespace anddatafile system tables created.

2015-05-27 12:07:52 3273 [Note] InnoDB: Waiting forpurge to start

2015-05-27 12:07:52 3273 [Note] InnoDB: 5.6.22started; log sequence number 0

2015-05-27 12:07:52 3273 [Note] RSA private key filenot found: /var/lib/mysql//private_key.pem. Some authentication plugins willnot work.

2015-05-27 12:07:52 3273 [Note] RSA public key filenot found: /var/lib/mysql//public_key.pem. Some authentication plugins will notwork.

A random root password has been set. You will find itin '/root/.mysql_secret'.

2015-05-27 12:07:55 3273 [Note] Binlog end

2015-05-27 12:07:55 3273 [Note] InnoDB: FTS optimizethread exiting.

2015-05-27 12:07:55 3273 [Note] InnoDB: Startingshutdown...

2015-05-27 12:07:57 3273 [Note] InnoDB: Shutdowncompleted; log sequence number 1625977

 

 

2015-05-27 12:07:57 0 [Warning] TIMESTAMP withimplicit DEFAULT value is deprecated. Please use--explicit_defaults_for_timestamp server option (see documentation for moredetails).

2015-05-27 12:07:57 3295 [Note] InnoDB: Using atomicsto ref count buffer pool pages

2015-05-27 12:07:57 3295 [Note] InnoDB: The InnoDBmemory heap is disabled

2015-05-27 12:07:57 3295 [Note] InnoDB: Mutexes andrw_locks use GCC atomic builtins

2015-05-27 12:07:57 3295 [Note] InnoDB: Memory barrieris not used

2015-05-27 12:07:57 3295 [Note] InnoDB: Compressedtables use zlib 1.2.3

2015-05-27 12:07:57 3295 [Note] InnoDB: Using Linuxnative AIO

2015-05-27 12:07:57 3295 [Note] InnoDB: Using CPUcrc32 instructions

2015-05-27 12:07:57 3295 [Note] InnoDB: Initializingbuffer pool, size = 128.0M

2015-05-27 12:07:57 3295 [Note] InnoDB: Completedinitialization of buffer pool

2015-05-27 12:07:57 3295 [Note] InnoDB: Highestsupported file format is Barracuda.

2015-05-27 12:07:57 3295 [Note] InnoDB: 128 rollbacksegment(s) are active.

2015-05-27 12:07:57 3295 [Note] InnoDB: Waiting forpurge to start

2015-05-27 12:07:57 3295 [Note] InnoDB: 5.6.22started; log sequence number 1625977

2015-05-27 12:07:57 3295 [Note] RSA private key filenot found: /var/lib/mysql//private_key.pem. Some authentication plugins willnot work.

2015-05-27 12:07:57 3295 [Note] RSA public key filenot found: /var/lib/mysql//public_key.pem. Some authentication plugins will notwork.

2015-05-27 12:07:57 3295 [Note] Binlog end

2015-05-27 12:07:57 3295 [Note] InnoDB: FTS optimizethread exiting.

2015-05-27 12:07:57 3295 [Note] InnoDB: Startingshutdown...

2015-05-27 12:07:59 3295 [Note] InnoDB: Shutdowncompleted; log sequence number 1625987

 

 

 

 

A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER!

You will find that password in '/root/.mysql_secret'.

 

You must change that password on your first connect,

no other statement but 'SET PASSWORD' will beaccepted.

See the manual for the semantics of the 'passwordexpired' flag.

 

Also, the account for the anonymous user has beenremoved.

 

In addition, you can run:

 

 /usr/bin/mysql_secure_installation

 

which will also give you the option of removing thetest database.

This is strongly recommended for production servers.

 

See the manual for more instructions.

 

Please report any problems at http://bugs.mysql.com/

 

The latest information about MySQL is available on theweb at

 

 http://www.mysql.com

 

Support MySQL by buying support/licenses athttp://shop.mysql.com

 

WARNING: Found existing config file /usr/my.cnf on thesystem.

Because this file might be in use, it was notreplaced,

but was used in bootstrap (unless you used--defaults-file)

and when you later start the server.

The new default config file was created as/usr/my-new.cnf,

please compare it with your file and take the changesyou need.

 

[root@promote mysql]# rpm -ivhMySQL-client-advanced-5.6.22-1.el7.x86_64.rpm

准备中...                         ################################# [100%]

正在升级/安装...

  1:MySQL-client-advanced-5.6.22-1.el################################# [100%][root@bogon桌面]#service mysql start

得到错误:ERROR!Theserver quit without updating PID file

我们这里主要是因为:selinux惹的祸,如果是centos系统,默认会开启selinux。解决方法是关闭它,打开/etc/selinux/config,把SELINUX=enforcing改为SELINUX=disabled后存盘退出重启机器。

 

#    disabled - No SELinux policy is loaded.

SELINUX=enforcing                               改成disabled

# SELINUXTYPE= can take one of three two values:

#    targeted - Targeted processes are protected,

#     minimum- Modification of targeted policy. Only selected processes are protected.

#     mls -Multi Level Security protection.

SELINUXTYPE=targeted


 

首次登陆:mysql安装完首次登陆的密码存放在这里,安装后会有提示

You will find that password in '/root/.mysql_secret'.

[root@web ~]# cat /root/.mysql_secret

# The random password set for the root user at TueApr 11 16:22:55 2017 (local time): kqy2gpU0wiDYWme8

其中kqy2gpU0wiDYWme8就是首次安装随机生成的密码通过个密码登陆mysql

[root@web ~]# mysql -u root –p首次以root用户登陆

Enter password: kqy2gpU0wiDYWme8

 

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 2

Server version:5.6.22-enterprise-commercial-advanced MySQL Enterprise Server - AdvancedEdition (Commercial)

 

Copyright (c) 2000, 2014, Oracle and/or itsaffiliates. All rights reserved.

 

Oracle is a registered trademark of OracleCorporation and/or its

affiliates. Other names may be trademarks of theirrespective

owners.

 

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

 

mysql> SET PASSWORD =PASSWORD("123456");重新配置密码为123456

Query OK, 0 rows affected (0.00 sec)

 

mysql> SHOW DATABASES;

+--------------------+

| Database          |

+--------------------+

| information_schema |

| mysql             |

| performance_schema |

| test              |

+--------------------+

4 rows in set (0.00 sec)

 

mysql> 


无法登陆修改密码

 

[root@promote mysql]# mysqld_safe--skip-grant-tables &   在后台远行,打开一个终端

[1] 3591

[root@promote mysql]# 150527 12:12:28 mysqld_safeLogging to '/var/lib/mysql/promote.cach   e-dns.local.err'.

150527 12:12:28 mysqld_safe Starting mysqld daemonwith databases from /var/lib/mysql

 

[root@promote ~]# mysql     登陆后台

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.6.22-enterprise-commercial-advancedMySQL Enterprise Server - Advanced Edition (Commercial)

 

Copyright (c) 2000, 2014, Oracle and/or itsaffiliates. All rights reserved.

 

Oracle is a registered trademark of OracleCorporation and/or its

affiliates. Other names may be trademarks of theirrespective

owners.

 

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

 

mysql> use mysql;

Reading table information for completion of tableand column names

You can turn off this feature to get a quickerstartup with -A

 

Database changed

mysql> UPDATE user SETpassword=password("root123") WHERE user="root";  修改密码

Query OK, 4 rows affected (0.00 sec)

Rows matched: 4 Changed: 4  Warnings: 0

mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.00 sec)

 

mysql> quit;

Bye

[root@promote ~]# service mysql restart  重启服务

Shutting down MySQL..150527 12:20:17 mysqld_safemysqld from pid file /var/lib/mysql/promote.cache-dns.local.pid ended

 SUCCESS!

Starting MySQL. SUCCESS!

[1]+  完成                  mysqld_safe--skip-grant-tables

 

[root@promote ~]# mysql -uroot -proot123   登陆

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version:5.6.22-enterprise-commercial-advanced

 

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

 

Oracle is a registered trademark of OracleCorporation and/or its

affiliates. Other names may be trademarks of theirrespective

owners.

 

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

 

mysql> show databases;

ERROR 1820 (HY000): You must SET PASSWORD beforeexecuting this statement

mysql> SETPASSWORD=PASSWORD("root123");  提示必须重新配置密码

Query OK, 0 rows affected (0.00 sec)

 

mysql> show databases;                   修改密码完成

+--------------------+

| Database          |

+--------------------+

| information_schema |

| mysql             |

| performance_schema |

| test              |

+--------------------+

4 rows in set (0.00 sec)

 

mysql>

允许任何远程主机连接

授权命令是:

grant 权限1,权限2,…权限n on 数据库名.表名 to用户名@用户地址 identified by‘口令’

[root@promote ~]# mysql -h192.168.1.200 -uroot -p  测试远程

Enter password:

ERROR 1130 (HY000): Host '192.168.1.200' is notallowed to connect to this MySQL server

[root@promote ~]# mysql -uroot -proot123

Warning: Using a password on the command lineinterface can be insecure.

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 9

Server version:5.6.22-enterprise-commercial-advanced MySQL Enterprise Server - AdvancedEdition (Commercial)

 

Copyright (c) 2000, 2014, Oracle and/or itsaffiliates. All rights reserved.

 

Oracle is a registered trademark of OracleCorporation and/or its

affiliates. Other names may be trademarks of theirrespective

owners.

 

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

 

mysql> grant all privileges on *.* to"root"@"%" identified by "root123"; 密码可以改

Query OK, 0 rows affected (0.00 sec)

 

mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.00 sec)

mysql> quit;

Bye

[root@promote ~]# service mysql restart

Shutting down MySQL.... SUCCESS!

Starting MySQL. SUCCESS!

 

防火墙放行端口

[root@promote ~]# firewall-cmd --zone=public--add-port=3306/tcp

Success

[root@promote ~]# firewall-cmd --zone=internal--add-port=3306/tcp

Success

 

查看自启动状态

[root@promote ~]# chkconfig --list mysql

 

注意:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。

      如果您想列出 systemd 服务,请执行'systemctl list-unit-files'。

      欲查看对特定 target 启用的服务请执行

     'systemctl list-dependencies [target]'。

 

mysql          0:关    1:关    2:关    3:关    4:关    5:关    6:关

[root@promote ~]# chkconfig mysql on

[root@promote ~]# chkconfig --list mysql

 

注意:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。

      如果您想列出 systemd 服务,请执行'systemctl list-unit-files'。

      欲查看对特定 target 启用的服务请执行

      'systemctllist-dependencies [target]'。

 

mysql          0:关    1:关    2:开    3:开    4:开    5:开    6:关

 

 

测试成功

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值