手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

RHEL Server 6.3下MySQL5.5.25a源码安装

[日期:2012-07-31] 来源:51cto  作者:scanlinux [字体:大 中 小]
(7)初始化数据库

[root@test scripts]# pwd

/usr/local/MySQL/scripts

[root@test scripts]# ll

total 16

-rwxr-xr-x. 1 mysql mysql 14816 Jul 13 14:50 mysql_install_db

[root@test scripts]#./mysql_install_db --datadir=/data1/mysql_db/

[root@test ~]#chown -R mysql:mysql /data1/mysql_db/  #根据具体情况决定做不做这一步。

------------------------------------------------------------------------------------------

注意:

mysql_install_db 脚本的目的是生成新的MySQL授权表。它不覆盖已有的MySQL授权表,并且它不影响任何其它数据。
如果你想要重新创建授权表,首先停止mysqld服务器(如果它正运行)。然后重新命名数据目录下的MySQL目录并保存,然后运行mysql_install_db。

本例中可用的参数:
#./mysql_install_db --user=mysql \
--defaults-file=/etc/my.cnf \
--basedir=/usr/local/mysql/ \
--datadir=/data1/mysql_db
------------------------------------------------------------------------------------------

(8)启动mysql
[root@test ~]# chkconfig --add mysqld
[root@test ~]# chkconfig --level 35 mysqld on
[root@test ~]# service mysqld start
 

------------------------------------------------------------------------------------------

注意:启动MySQL时出现以下错误:

[root@test ~]# service mysqld start

Starting MySQL.The server quit without updating PID file (/[FAILED]mysql/mysql.pid).

[root@test ~]# tail /var/log/mysql.log

120713 16:41:36 mysqld_safe Starting mysqld daemon with databases from /data1/mysql_db

/usr/local/mysql/bin/mysqld: Character set 'all' is not a compiled character set and is not specified in the '/usr/local/mysql/share/charsets/Index.xml' file

120713 16:41:36 [ERROR] Aborting


120713 16:41:36 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete


120713 16:41:36 mysqld_safe mysqld from pid file /var/run/mysql/mysql.pid ended

[root@test ~]#

错误原因:
这是因为我在编译 MySQL 的时候加上了 -DDEFAULT_CHARSET=all 参数。最好设为-DDEFAULT_CHARSET=utf8。

解决方法:
修改配置文件/etc/my.cnf文件,在[mysql]下加入character-set-server = utf8。

[mysqld]

character-set-server = utf8

------------------------------------------------------------------------------------------

(9)设置 mysql 用户 root 的密码

[root@test ~]# mysqladmin -u root -p password 123456

[root@test ~]# mysql -u root -p -S /tmp/mysql.sock

Enter password:  <-----输入上面设置的数据库管理员密码:123456,回车即可登录数据库。

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

Your MySQL connection id is 3

Server version: 5.5.25a-log Source distribution


Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.


Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql>

如下图:

在初始化 mysql 数据库后,其中默认生成了4个数据库;每个数据库下都会有若干个表。

linux
相关资讯       MySQL安装 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款