redhat linux下面mysql的安装

时间:2021-07-21 09:06:38

首先需要卸载redhat自带的mysql版本 这里通过rpm -qa | grep mysql的方式查找并删除

<span style="font-size:18px;">[root@cluster1 hadoop]# rpm -qa | grep mys
mysql-libs-5.1.71-1.el6.x86_64
mysql-devel-5.1.71-1.el6.x86_64
mysql-5.1.71-1.el6.x86_64</span>

卸载我们通过强制卸载的方式卸载 命令如下:

<span style="font-size:18px;">[root@cluster1 hadoop]# rpm -e mysql-libs-5.1.71-1.el6.x86_64 --nodeps
[root@cluster1 hadoop]# rpm -qa | grep mys
mysql-devel-5.1.71-1.el6.x86_64
mysql-5.1.71-1.el6.x86_64
[root@cluster1 hadoop]# rpm -e --nodeps mysql-devel-5.1.71-1.el6.x86_64
[root@cluster1 hadoop]# rpm -e --nodeps mysql-5.1.71-1.el6.x86_64</span>

卸载完成我们需要下载最新的Mysql安装包 可以通过编译的方式和rpm安装包安装的方式 这里我们通过rpm的方式来安装:

[hadoop@cluster1 ~]$ tar -xvf MySQL-5.6.17-1.linux_glibc2.5.x86_64.rpm-bundle.tar 
MySQL-devel-5.6.17-1.linux_glibc2.5.x86_64.rpm
MySQL-shared-5.6.17-1.linux_glibc2.5.x86_64.rpm
MySQL-test-5.6.17-1.linux_glibc2.5.x86_64.rpm
MySQL-server-5.6.17-1.linux_glibc2.5.x86_64.rpm
MySQL-embedded-5.6.17-1.linux_glibc2.5.x86_64.rpm
MySQL-shared-compat-5.6.17-1.linux_glibc2.5.x86_64.rpm
MySQL-client-5.6.17-1.linux_glibc2.5.x86_64.rpm

这里我们下载的是5.6.17的版本 然后我们解压到相应路径下面,我们只需要安装server和client就可以了

首先安装Server:

[root@cluster1 hadoop]# rpm -ivh MySQL-server-5.6.17-1.linux_glibc2.5.x86_64.rpm 
Preparing... ########################################### [100%]
1:MySQL-server ########################################### [100%]
2014-08-12 16:22:15 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-08-12 16:22:15 3764 [Note] InnoDB: Using atomics to ref count buffer pool pages
2014-08-12 16:22:15 3764 [Note] InnoDB: The InnoDB memory heap is disabled
2014-08-12 16:22:15 3764 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-08-12 16:22:15 3764 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-08-12 16:22:15 3764 [Note] InnoDB: Using Linux native AIO
2014-08-12 16:22:15 3764 [Note] InnoDB: Not using CPU crc32 instructions
2014-08-12 16:22:15 3764 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-08-12 16:22:15 3764 [Note] InnoDB: Completed initialization of buffer pool
2014-08-12 16:22:16 3764 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2014-08-12 16:22:16 3764 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2014-08-12 16:22:16 3764 [Note] InnoDB: Database physically writes the file full: wait...
2014-08-12 16:22:16 3764 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2014-08-12 16:22:19 3764 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2014-08-12 16:22:23 3764 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2014-08-12 16:22:23 3764 [Warning] InnoDB: New log files created, LSN=45781
2014-08-12 16:22:23 3764 [Note] InnoDB: Doublewrite buffer not found: creating new
2014-08-12 16:22:23 3764 [Note] InnoDB: Doublewrite buffer created
2014-08-12 16:22:24 3764 [Note] InnoDB: 128 rollback segment(s) are active.
2014-08-12 16:22:25 3764 [Warning] InnoDB: Creating foreign key constraint system tables.
2014-08-12 16:22:25 3764 [Note] InnoDB: Foreign key constraint system tables created
2014-08-12 16:22:25 3764 [Note] InnoDB: Creating tablespace and datafile system tables.
2014-08-12 16:22:25 3764 [Note] InnoDB: Tablespace and datafile system tables created.
2014-08-12 16:22:25 3764 [Note] InnoDB: Waiting for purge to start
2014-08-12 16:22:25 3764 [Note] InnoDB: 5.6.17 started; log sequence number 0
A random root password has been set. You will find it in '/root/.mysql_secret'.
2014-08-12 16:22:38 3764 [Note] Binlog end
2014-08-12 16:22:38 3764 [Note] InnoDB: FTS optimize thread exiting.
2014-08-12 16:22:38 3764 [Note] InnoDB: Starting shutdown...
2014-08-12 16:22:39 3764 [Note] InnoDB: Shutdown completed; log sequence number 1625977


2014-08-12 16:22:40 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-08-12 16:22:40 3789 [Note] InnoDB: Using atomics to ref count buffer pool pages
2014-08-12 16:22:40 3789 [Note] InnoDB: The InnoDB memory heap is disabled
2014-08-12 16:22:40 3789 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-08-12 16:22:40 3789 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-08-12 16:22:40 3789 [Note] InnoDB: Using Linux native AIO
2014-08-12 16:22:40 3789 [Note] InnoDB: Not using CPU crc32 instructions
2014-08-12 16:22:40 3789 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-08-12 16:22:40 3789 [Note] InnoDB: Completed initialization of buffer pool
2014-08-12 16:22:40 3789 [Note] InnoDB: Highest supported file format is Barracuda.
2014-08-12 16:22:40 3789 [Note] InnoDB: 128 rollback segment(s) are active.
2014-08-12 16:22:40 3789 [Note] InnoDB: Waiting for purge to start
2014-08-12 16:22:40 3789 [Note] InnoDB: 5.6.17 started; log sequence number 1625977
2014-08-12 16:22:43 3789 [Note] Binlog end
2014-08-12 16:22:43 3789 [Note] InnoDB: FTS optimize thread exiting.
2014-08-12 16:22:43 3789 [Note] InnoDB: Starting shutdown...
2014-08-12 16:22:45 3789 [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@cluster1 hadoop]#
[root@cluster1 hadoop]# rpm -ivh MySQL-client-5.6.17-1.linux_glibc2.5.x86_64.rpm Preparing...                ########################################### [100%]   1:MySQL-client           ########################################### [100%]
这时候已经安装完成了 我们可以通过命令查看mysql是否已经启动

[root@cluster1 hadoop]#  /etc/rc.d/init.d/mysql status
MySQL is not running [FAILED]
[root@cluster1 hadoop]# /etc/rc.d/init.d/mysql start
Starting MySQL... [ OK ]
[root@cluster1 hadoop]# /etc/rc.d/init.d/mysql status
MySQL running (4211) [ OK ]
[root@cluster1 hadoop]#


出现此错误时:

# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)


 1.关闭mysql服务

    # service mysql stop

 2.屏蔽权限

    # mysqld_safe --skip-grant-table    &

   3. 新开起一个终端输入

 mysql -u root mysql    mysql> UPDATE user SET Password=PASSWORD('newpassword') 

where 

USER='root';  

mysql> FLUSH  PRIVILEGES;//

记得要这句话,否则如果关闭先前的

终端,又会出现原来的错误

 



mysql> show databases;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

mysql安装过程中出现错误ERROR 1820 (HY000): You must SET PASSWORD before executing this statement解决   最近新装好的mysql在进入mysql工具时,总是有错误提示: # mysql -u root -p Enter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) 或者 # mysql -u root -p password 'newpassword' Enter password: mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: YES)'    现在终于找到解决方法了。本来准备重装的,现在不必了。 方法操作很简单,如下: # /etc/init.d/mysql stop # mysqld_safe --user=mysql --skip-grant-tables --skip-networking & # mysql -u root mysql mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root' and host='root' or host='localhost';//把空的用户密码都修改成非空的密码就行了。 mysql> FLUSH PRIVILEGES; mysql> quit # /etc/init.d/mysqld restart # mysql -uroot -p Enter password: <输入新设的密码newpassword>   MySql5.6操作时报错:You must SET PASSWORD before executing this statement解决 mysql>  SET PASSWORD = PASSWORD('123456'); Query OK, 0 rows affected (0.03 sec) mysql> create database roger; Query OK, 1 row affected (0.00 sec) 也就是用mysql>  SET PASSWORD = PASSWORD('123456');这句话重新设置一次密码!