现在的位置: 首页 > 综合 > 正文

LINUX下MYSQL的启动及相关配置

2018年05月28日 ⁄ 综合 ⁄ 共 1724字 ⁄ 字号 评论关闭

一.一般安装完LINUX后,MYSQL没有经过配置就用如下命令启动MYSQL会出错的.

# service mysqld start

初始化 MySQL 数据库: Neither host 'localhost.localdomain' nor 'localhost' could be looked up with

/usr/bin/resolveip

Please configure the 'hostname' command to return a correct hostname.

If you want to solve this at a later stage, restart this script with

the --force option

[失败]

解决办法:

1、$ ping localhost

ping: unknown host localhost

ping也不成功,确定可能为localhost解析原因。

2、查看/etc/hosts,内容如下:

# Do not remove the following line, or various programs

# that require network functionality will fail.

::1 localhost.localdomain localhost

3、将::1修改为127.0.0.1后,保存退出。

二.启动mysql:

(1)#service mysql start

(2)#/etc/init.d/mysqld start

启动 MySQL:                                               [确定]

三.停止MySQL可以用如下命令:

(1)#service mysql stop

(2)#/etc/init.d/mysqld stop

停止 MySQL:                                               [确定]

(3)#mysqladmin shutdown

mysqld 已死,但是 subsys 被锁

四.检验MySQL是否被启动

#service mysqld status

mysqld (pid 5659) 正在运行...

五.连接进入MySQL数据库

#mysql

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

Your MySQL connection id is 2 to server version: 5.0.22

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

这是第一次进入MySQL数据库,只有是root才能进入,默认密码为空。

要退出数据库只需键入'\q'就行了。

mysql>\q

Bye

#

六.设置MySQL管理员的密码

# mysqladmin -u root password 密码字符窜

设置好后再用mysql进行连接将会出错。

# mysql

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

应用如下命令:

# mysql -u root -p

Enter password:

在输入正确密码后将输出如下结果并进入数据库。

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

Your MySQL connection id is 4 to server version: 5.0.22

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

七.修改MySQL管理员的密码

[root@localhost ~]# mysqladmin -u root -p password 新密码字符窜

Enter password:

此时系统会提示你要输入旧密码,只有输入的密码正确才会修改成功。否则将会出错:

mysqladmin: connect to server at 'localhost' failed

error: 'Access denied for user 'root'@'localhost' (using password: YES)'

以上操作都是在CentOS LINUX5.0 下实现的,在其它版本的LINUX配置MYSQL的命令也一样

抱歉!评论已关闭.