1. 程式人生 > >虛擬機器搭建CDH-第六講-安裝mysql第二種方法(通過rpm包安裝)

虛擬機器搭建CDH-第六講-安裝mysql第二種方法(通過rpm包安裝)

1.上傳安裝檔案到linux

MySQL-client-5.5.48-1.linux2.6.x86_64.rpm

MySQL-server-5.5.48-1.linux2.6.x86_64.rpm


2.使用rpm命令安裝mysql

rpm -ivh MySQL-server-5.5.48-1.linux2.6.x86_64.rpm

3.mini版本linux安裝mysql執行上面語句會報錯,說明缺少依賴


4.安裝perl依賴,libaio-0.3.107-10.el6.x86_64.rpm


5.安裝依賴 rpm -ivh libaio-0.3.107-10.el6.x86_64.rpm


6.再安裝mysql-server,rpm包衝突


8.解除安裝衝突的rpm包

 rpm -e mysql-libs-5.1.73-5.el6_6.x86_64 --nodeps

9.再安裝mysql-server和mysql-client



10.啟動mysql服務,然後初始化mysql

service  mysql start

/usr/bin/mysql_secure_installation 進行初始化

11.初始化

NOTE: RUNNING ALL PARTS OF THIS SCRIPT ISRECOMMENDED FOR ALL MySQL

     SERVERS IN PRODUCTION USE!  PLEASEREAD EACH STEP CAREFULLY!

In order to log into MySQL to secure it,we'll need the current

password for the root user.  If you've just installed MySQL, and

you haven't set the root password yet, thepassword will be blank,

so you should just press enter here.

Enter current password for root (enter fornone):這裡直接回車

OK, successfully used password, movingon...

Setting the root password ensures thatnobody can log into the MySQL

root user without the proper authorisation.

Set root password? [Y/n] Y

New password:設定mysql root使用者密碼

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

 ...Success!

By default, a MySQL installation has ananonymous user, allowing anyone

to log into MySQL without having to have auser account created for

them. This is intended only for testing, and to make the installation

go a bit smoother.  You should remove them before moving into a

production environment.

Remove anonymous users? [Y/n] Y

 ...Success!

Normally, root should only be allowed toconnect from 'localhost'.  This

ensures that someone cannot guess at theroot password from the network.

Disallow root login remotely? [Y/n] Y

 ...Success!

By default, MySQL comes with a database named'test' that anyone can

access. This is also intended only for testing, and should be removed

before moving into a productionenvironment.

Remove test database and access to it?[Y/n] Y

 -Dropping test database...

 ...Success!

 -Removing privileges on test database...

 ...Success!

Reloading the privilege tables will ensurethat all changes made so far

will take effect immediately.

Reload privilege tables now? [Y/n] Y

 ...Success!

Cleaning up...

All done! If you've completed all of the above steps, your MySQL

installation should now be secure.

Thanks for using MySQL!


12.登入 mysql -uroot -proot

13.如果出現使用者無法登入情況

   狀況如下

        mysql -uroot -proot

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

如出現此錯誤

按照下面操作

 1.停止mysqld服務

     service mysqld stop

 2.以跳過授權的方式啟動mysql

      mysqld_safe --skip-grant-tables &

3.以root使用者登入mysql

      mysql -u root

4.進入mysql資料庫

    mysql> use mysql

5.更新mysql資料庫中的user表的root的password欄位

    mysql> update user set password=PASSWORD("new_password") where User="root";

6.重新整理許可權,使其立即生效,之後退出mysql,並重新啟動mysql

    mysql> flush privileges;

    mysql> quit

    # service  restart