在centos环境下安装Msql包括修改密码

安装Mysql

下载最新版本的是MySQL-5.6.25-1.linux_glibc2.5.x86_64.rpm-bundle.tar

建立文件夹/usr/local/mysql/

解压有客户端和服务端版本

安装Mysql客户端软件包

安装之前,检查以下是否有 mariadb软件包,否则会出现文件冲出,出现以下情况(错误信息)

[root@localhost  mysql]# rpm -ivh MySQL-server-5.6.25-1.linux_glibc2.5.x86_64.rpm

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

file /usr/share/mysql/charsets/README from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/czech/errmsg.sys from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/danish/errmsg.sys from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/dutch/errmsg.sys from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/english/errmsg.sys from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/estonian/errmsg.sys from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/french/errmsg.sys from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/german/errmsg.sys from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/greek/errmsg.sys from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/hungarian/errmsg.sys from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/italian/errmsg.sys from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/japanese/errmsg.sys from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/korean/errmsg.sys from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/norwegian-ny/errmsg.sys from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/norwegian/errmsg.sys from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/polish/errmsg.sys from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/portuguese/errmsg.sys from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/romanian/errmsg.sys from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/russian/errmsg.sys from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/serbian/errmsg.sys from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/slovak/errmsg.sys from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/spanish/errmsg.sys from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/swedish/errmsg.sys from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/ukrainian/errmsg.sys from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/charsets/Index.xml from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/charsets/armscii8.xml from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/charsets/ascii.xml from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/charsets/cp1250.xml from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/charsets/cp1251.xml from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/charsets/cp1256.xml from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/charsets/cp1257.xml from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/charsets/cp850.xml from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/charsets/cp852.xml from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/charsets/cp866.xml from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/charsets/dec8.xml from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/charsets/geostd8.xml from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/charsets/greek.xml from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/charsets/hebrew.xml from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/charsets/hp8.xml from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/charsets/keybcs2.xml from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/charsets/koi8r.xml from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/charsets/koi8u.xml from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/charsets/latin1.xml from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/charsets/latin2.xml from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/charsets/latin5.xml from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/charsets/latin7.xml from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/charsets/macce.xml from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/charsets/macroman.xml from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

file /usr/share/mysql/charsets/swe7.xml from install of MySQL-server-5.6.25-1.linux_glibc2.5.x86_64 conflicts with file from package mariadb-libs-1:5.5.41-2.el7_0.x86_64

查看是否有mariadb 软件包

[root@localhost  ~]#  rpm -qa | grep mariadb

mariadb-libs-5.5.41-2.el7_0.x86_64

卸载mariadb 相关的软件包

[root@localhost  ~]# rpm -e --nodeps mariadb-libs-5.5.41-2.el7_0.x86_64


安装服务端mysql

[root@localhost  mysql]# rpm -ivh MySQL-server-5.6.25-1.linux_glibc2.5.x86_64.rpm

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

正在升级/安装...

1:MySQL-server-5.6.25-1.linux_glibc################################# [100%]

警告:用户mysql 不存在 - 使用root

警告:群组mysql 不存在 - 使用root

2015-07-01 10:21:33 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2015-07-01 10:21:33 0 [Note] /usr/sbin/mysqld (mysqld 5.6.25) starting as process 50849 ...

2015-07-01 10:21:33 50849 [Note] InnoDB: Using atomics to ref count buffer pool pages

2015-07-01 10:21:33 50849 [Note] InnoDB: The InnoDB memory heap is disabled

2015-07-01 10:21:33 50849 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

2015-07-01 10:21:33 50849 [Note] InnoDB: Memory barrier is not used

2015-07-01 10:21:33 50849 [Note] InnoDB: Compressed tables use zlib 1.2.3

2015-07-01 10:21:33 50849 [Note] InnoDB: Using Linux native AIO

2015-07-01 10:21:33 50849 [Note] InnoDB: Using CPU crc32 instructions

2015-07-01 10:21:33 50849 [Note] InnoDB: Initializing buffer pool, size = 128.0M

2015-07-01 10:21:33 50849 [Note] InnoDB: Completed initialization of buffer pool

2015-07-01 10:21:33 50849 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!

2015-07-01 10:21:33 50849 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB

2015-07-01 10:21:33 50849 [Note] InnoDB: Database physically writes the file full: wait...

2015-07-01 10:21:33 50849 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB

2015-07-01 10:21:35 50849 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB

2015-07-01 10:21:36 50849 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0

2015-07-01 10:21:36 50849 [Warning] InnoDB: New log files created, LSN=45781

2015-07-01 10:21:36 50849 [Note] InnoDB: Doublewrite buffer not found: creating new

2015-07-01 10:21:36 50849 [Note] InnoDB: Doublewrite buffer created

2015-07-01 10:21:36 50849 [Note] InnoDB: 128 rollback segment(s) are active.

2015-07-01 10:21:36 50849 [Warning] InnoDB: Creating foreign key constraint system tables.

2015-07-01 10:21:36 50849 [Note] InnoDB: Foreign key constraint system tables created

2015-07-01 10:21:36 50849 [Note] InnoDB: Creating tablespace and datafile system tables.

2015-07-01 10:21:36 50849 [Note] InnoDB: Tablespace and datafile system tables created.

2015-07-01 10:21:36 50849 [Note] InnoDB: Waiting for purge to start

2015-07-01 10:21:36 50849 [Note] InnoDB: 5.6.25 started; log sequence number 0

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

2015-07-01 10:21:36 50849 [Note] Binlog end

2015-07-01 10:21:36 50849 [Note] InnoDB: FTS optimize thread exiting.

2015-07-01 10:21:36 50849 [Note] InnoDB: Starting shutdown...

2015-07-01 10:21:38 50849 [Note] InnoDB: Shutdown completed; log sequence number 1625977

2015-07-01 10:21:38 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2015-07-01 10:21:38 0 [Note] /usr/sbin/mysqld (mysqld 5.6.25) starting as process 50872 ...

2015-07-01 10:21:38 50872 [Note] InnoDB: Using atomics to ref count buffer pool pages

2015-07-01 10:21:38 50872 [Note] InnoDB: The InnoDB memory heap is disabled

2015-07-01 10:21:38 50872 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

2015-07-01 10:21:38 50872 [Note] InnoDB: Memory barrier is not used

2015-07-01 10:21:38 50872 [Note] InnoDB: Compressed tables use zlib 1.2.3

2015-07-01 10:21:38 50872 [Note] InnoDB: Using Linux native AIO

2015-07-01 10:21:38 50872 [Note] InnoDB: Using CPU crc32 instructions

2015-07-01 10:21:38 50872 [Note] InnoDB: Initializing buffer pool, size = 128.0M

2015-07-01 10:21:38 50872 [Note] InnoDB: Completed initialization of buffer pool

2015-07-01 10:21:38 50872 [Note] InnoDB: Highest supported file format is Barracuda.

2015-07-01 10:21:38 50872 [Note] InnoDB: 128 rollback segment(s) are active.

2015-07-01 10:21:38 50872 [Note] InnoDB: Waiting for purge to start

2015-07-01 10:21:38 50872 [Note] InnoDB: 5.6.25 started; log sequence number 1625977

2015-07-01 10:21:38 50872 [Note] Binlog end

2015-07-01 10:21:38 50872 [Note] InnoDB: FTS optimize thread exiting.

2015-07-01 10:21:38 50872 [Note] InnoDB: Starting shutdown...

2015-07-01 10:21:40 50872 [Note] InnoDB: Shutdown completed; 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 be accepted.

See the manual for the semantics of the 'password expired' flag.

Also, the account for the anonymous user has been removed.

In addition, you can run:

/usr/bin/mysql_secure_installation

which will also give you the option of removing the test 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 the web at

http://www.mysql.com

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

New default config file was created as /usr/my.cnf and

will be used by default by the server when you start it.

You may edit this file to change server settings

[root@localhost  mysql]#  

检查一下mysql服务端是否安装成功

[root@localhost mysql]#    service mysql start  

Starting MySQL... SUCCESS!  

[root@localhost mysql]#  

出现以上情况,说明安装成功

安装客户端MySQL-client-5.6.25-1.linux_glibc2.5.x86_64.rpm

[root@localhost mysql]# rpm -ivh MySQL-client-5.6.25-1.linux_glibc2.5.x86_64.rpm

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

正在升级/安装...

  1:MySQL-client-5.6.25-1.linux_glibc################################# [100%]

[root@localhost mysql]#  

出现以上情况,已经成功安装

查看3306端口号

[root@localhost mysql]# netstat -ntlp | grep 3306

tcp6       0      0 :::3306                 :::*                    LISTEN      51071/mysqld        

[root@localhost mysql]#  





安装完mysql之后,默认用户名为root ,密码为空

[root@localhost mysql]# mysql -u root -p

Enter password:  

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

停止服务

[root@localhost mysql]# /etc/rc.d/init.d/mysql stop

Shutting down MySQL.. SUCCESS!  

[root@localhost mysql]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

[1] 52352

[root@localhost mysql]# 150701 10:38:15 mysqld_safe Logging to '/var/lib/mysql/localhost.err'.

150701 10:38:15 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

用户组为mysql

[root@localhost mysql]# mysql -u root mysql  

Reading table information for completion of table and column names

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

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

Your MySQL connection id is 1

Server version: 5.6.25 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, 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.

root账户设置密码

mysql>  update user set password = password('123456') where user = 'root' and host='root' or host = 'localhost' ;

Query OK, 1 row affected (0.00 sec)

Rows matched: 1  Changed: 1  Warnings: 0

强制刷新Mysql

mysql>  flush privileges;  

Query OK, 0 rows affected (0.00 sec)

退出mysql

mysql> quit;

Bye

[root@localhost mysql]# mysql -u root -p

Enter password:  

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

Your MySQL connection id is 2

Server version: 5.6.25

Copyright (c) 2000, 2015, 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;

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

mysql>

结果发现提示是错误的

重新执行:

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

Query OK, 0 rows affected (0.00 sec)


mysql> show databases;

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

| Database           |

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

| information_schema |

| jeecg_gjh          |

| mysql              |

| performance_schema |

| test               |

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

5 rows in set (0.00 sec)

mysql>

说明mysql已经安装成功



你可能感兴趣的:(在centos环境下安装Msql包括修改密码)