虚拟机搭建CDH-第六讲-安装mysql第二种方法(通过rpm包安装)

来源:互联网 发布:公司seo是什么职位 编辑:程序博客网 时间:2024/06/01 08:29

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


0 0