首页 » Mysql安装

从源代码安装Mysql

添加Mysql用户和组

# groupadd mysql
# useradd -g mysql mysql

编译Mysql

$ ./configure --prefix=/usr/local/mysql --with-charset=utf8  --with-readline --enable-thread-safe-client

$ make

# make install

把配置文件复制到合适的位置:

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

初始化数据库:

# cd /usr/local/mysql

# ./bin/mysql_install_db

修改Mysql路径的用户/组属性:

# cd /usr/local/mysql/
 
# chgrp -R mysql ./mysql
 
# chown  -R mysql ./mysql

设置Mysql为系统服务,开机自启动:

# cp share/mysql/mysql.server /etc/init.d/mysql

# chmod +x /etc/init.d/mysql

# chkconfig --add mysql

关闭Mysql:

# mysqladmin shutdown

MySQL服务器状态

status查看版本号、Socket配置等信息:

mysql> status;
--------------
mysql  Ver 14.14 Distrib 5.1.58, for pc-linux-gnu (i686) using  EditLine wrapper

Connection id:          1
Current database:       tbring
Current user:           bailing@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         5.1.58-log Source distribution
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    utf8
Db     characterset:    utf8
Client characterset:    utf8
Conn.  characterset:    utf8
UNIX socket:            /tmp/mysql.sock
Uptime:                 13 min 41 sec

Threads: 1  Questions: 12  Slow queries: 0  Opens: 18  Flush tables: 1  Open tables: 10  Queries per second avg: 0.14
--------------

查看版本号:

mysql> select version();
+------------+
| version()  |
+------------+
| 5.1.58-log |
+------------+
1 row in set (0.01 sec)

参考

MySQL 5.1 参考手册 第15章:存储引擎和表类型

分享

0