网络安全 频道

如何安全配置和应用MySQL数据库(2)

3.配置与启动

  MySQL的配置文件需要手工选择、拷贝几个模板文件中的一个到/etc下,这几个模板文件位于源文件的support-files目录,一共有4个:small、medium、large、huge。

#cp support-files/my-medium.cnf /etc/my.cnf

#chown root:sys /etc/my.cnf

#chmod 644 /etc/my.cnf

  启动MySQL,注意使用用户为mysql:

  #/usr/local/mysq/bin/mysqld_safe --user=mysql &

  4.测试

  为了测试安装的程序是否正确及MySQL是否已经正常启动,最好的办法就是用MySQL客户端来连接数据库。

#/usr/local/mysql/bin/mysql

[root@ftp bin]# mysql

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

Your MySQL connection id is 687 to server version: 3.23.58

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

mysql>

mysql> show databases;

+--------------+

  Database  

+--------------+

  mysql  

  test  

+--------------+

2 rows in set (0.00 sec)

mysql>quit

  连接成功,可以关闭数据库:

#/usr/local/mysql/bin/mysqladmin -uroot shutdown

  如果连接失败则需要仔细分析出错原因:

#more /usr/local/mysql/var/`hostname`.err

0
相关文章