通过RPM包安装Mysql

安装mysql时的一些问题

通过RPM包安装Mysql
 

从安装开始谈MySQL安全

 

由于公司最近的也去需要,需要安装Mysql作为数据服务器,服务器版本是redhat6。在redhat6的光盘中找到Mysql的RPM包就直接用RPM包来安装Mysql,期间遇到看种种问题。
  www.2cto.com  
网上的介绍基本上都是一样的。先安装server,然后再安装client。但是我的server始终安装不上,总是提示

 

问题如下:

澳门金沙vip 1

当你安装 MySQL 完后、会有个提示:

 

然后按照提示安装perl-DBD-Mysql的相关包,还是报错。后来发现这个包和mysql的server包存在互相依赖,所以将安装服务器端的命令改为:
  www.2cto.com  

 

 /usr/bin/mysql_secure_installation

1.rpm -ivh mysql-server-5.1.47-4.el6.x86_64.rpm –nodeps

[[email protected]
Desktop]# rpm -ivh MySQL-server-5.5.28-1.rhel5.i386.rpm

 

安装成功

Preparing…              
 ###########################################
[100%]

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL

2.启动mysql 

   1:MySQL-server          
###########################################
[100%]

      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

/etc/init.d/mysqld start 

 

 

无法启动,这时按照提示运行命令   www.2cto.com  

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !

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

chown -R mysql:mysql /var/lib/mysql

To do so, start the server, then issue the following commands:

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

再次启动启动成功

 

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

3.设置mysql root用户的密码:mysqladmin -uroot password ‘密码’

/usr/bin/mysqladmin -u root password ‘new-password’

so you should just press enter here.

4.登录测试:mysql -u root -p

澳门金沙vip,/usr/bin/mysqladmin -u root -h localhost.localdomain password
‘new-password’

 

5.备份数据库:mysqldump –add-drop-table –opt test > backup-file.sql

 

Enter current password for root (enter for none): 

以下内容自己就比较懒了是转载的

Alternatively you can run:

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

Mysql相关设置
1,密码和登陆设置
我们可以用命令 mysql_secure_installation进行相关的设置
mysql_secure_installation

/usr/bin/mysql_secure_installation

 

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

**对于这 2 种方式、我个人认为、mysql_secure_installation
比较好用***

解决办法:

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, the password will be blank,
so you should just press enter here.

 

 

Enter current password for root (enter for none):
这里我已经通过命令mysqladmin 更改过默认密码 语法为:
mysqladmin -uroot password ‘newpassword’
这里我们键入新密码
[[email protected]
~]# mysql_secure_installation

which will also give you the option of removing the test

登陆mysql

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

databases and anonymous user created by default.  This is

 

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, the password will be blank,
so you should just press enter here.

strongly recommended for production servers.

如果无法登陆mysql
可以在my.cnf中增加skip-grant-tables;跳过验证,登陆mysql后重新设置一下密码

Enter current password for root (enter for none):
OK, successfully used password, moving on…

 

 

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

**我觉得、这里的关键应该是能够把匿名用户给删掉***

set password=password(‘123456’);

You already have a root password set, so you can safely answer ‘n’.

See the manual for more instructions.

 

Change the root password? [Y/n] n
… skipping.

 

然后运行

By default, a MySQL installation has an anonymous user, allowing
anyone
to log into MySQL without having to have a user 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.

Please report any problems with the /usr/bin/mysqlbug script!

 

Remove anonymous users? [Y/n] y
… Success!

 

/usr/bin/mysql_secure_installation

Normally, root should only be allowed to connect from ‘localhost’.
This
ensures that someone cannot guess at the root password from the
network.

By default, a MySQL installation has an anonymous user, allowing anyone

 

Disallow root login remotely? [Y/n] y
… Success!

to log into MySQL without having to have a user account created for

进行安全设置就可以了

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 production environment.

them.  This is intended only for testing, and to make the installationgo
a bit smoother. 

 

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

 You should remove them before moving into a production environment

搞定收工

Reloading the privilege tables will ensure that all changes made so
far
will take effect immediately.