本文档记录安装Percona-Server开发环境,非生产环境使用
1.下载Percona-Server-5.5.38-rel35.2-674.Linux.x86_64.tar.gz
下载地址
http://www.percona.com/downloads/Percona-Server-5.5/Percona-Server-5.5.38-35.2/binary/tarball/
2. 执行安装脚本
cd script
./mysql_install_db --user=admin --basedir=/home/admin/jyp/mysql --datadir=/home/admin/jyp/mysql/data
可能会出现如下错误提示,忽略:
Installing MySQL system tables...
Error in my_thread_global_end(): 1 threads didn't exit
OK
Filling help tables...
Error in my_thread_global_end(): 1 threads didn't exit
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/home/admin/jyp/mysql/bin/mysqladmin -u root password 'new-password'
/home/admin/jyp/mysql/bin/mysqladmin -u root -h v125048147.bja password 'new-password'
3. 启动mysql
mysql的配置文件在support-files目录
下面是最简单的启动方法:
[admin@v125048147 mysql]$ ./bin/mysqld_safe --user=yunpeng --basedir=/home/admin/jyp/mysql --datadir=/home/admin/jyp/mysql/data
140728 23:05:06 mysqld_safe Logging to '/home/admin/jyp/mysql/data/v125048147.bja.err'.
140728 23:05:06 mysqld_safe Starting mysqld daemon with databases from /home/admin/jyp/mysql/data
在日志可以看到如下信息,启动成功:
140728 23:05:06 mysqld_safe Starting mysqld daemon with databases from /home/admin/jyp/mysql/data
140728 23:05:06 [Note] Plugin 'FEDERATED' is disabled.
140728 23:05:06 InnoDB: The InnoDB memory heap is disabled
140728 23:05:06 InnoDB: Mutexes and rw_locks use GCC atomic builtins
140728 23:05:06 InnoDB: Compressed tables use zlib 1.2.3
140728 23:05:06 InnoDB: Using Linux native AIO
140728 23:05:06 InnoDB: Initializing buffer pool, size = 128.0M
140728 23:05:06 InnoDB: Completed initialization of buffer pool
140728 23:05:06 InnoDB: highest supported file format is Barracuda.
140728 23:05:06 InnoDB: Waiting for the background threads to start
140728 23:05:07 Percona XtraDB (http://www.percona.com) 5.5.38-35.2 started; log sequence number 1597945
140728 23:05:07 [Note] Event Scheduler: Loaded 0 events
140728 23:05:07 [Note] /home/admin/jyp/mysql/bin/mysqld: ready for connections.
Version: '5.5.38-35.2' socket: '/tmp/mysql.sock' port: 3306 Percona Server (GPL), Release 35.2, Revision 674
注意一定要在mysql目录执行./bin/mysqld_safe,貌似是从相对路径读取配置信息
比如在home目录执行如下会报错
/home/admin/jyp/mysql/bin/mysqld_safe --user=admin --basedir=/home/admin/jyp/mysql --datadir=/home/admin/jyp/mysql/data
[admin@v125048147 ~]$ /home/admin/jyp/mysql/bin/mysqld_safe --user=admin --basedir=/home/admin/jyp/mysql --datadir=/home/admin/jyp/mysql/data
140822 16:40:55 mysqld_safe Logging to '/var/log/mysqld.log'.
140822 16:40:55 mysqld_safe The file /usr/local/Percona-Server-5.5.38-rel35.2-674.Linux.x86_64/bin/mysqld
does not exist or is not executable. Please cd to the mysql installation
directory and restart this script from there as follows:
./bin/mysqld_safe&
See http://dev.mysql.com/doc/mysql/en/mysqld-safe.html for more information
另外通过admin帐号启动会报这个错误
140822 16:43:22 [ERROR] /home/admin/jyp/mysql/bin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 13)
140822 16:43:22 [ERROR] Can't start server: can't create PID file: Permission denied
只好把/var/run/mysqld的权限改掉解决
补充
如果/etc/my.cnf 存在,会加载/etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
更好的方式:
mysqld_safe --defaults-file=/duitang/dist/conf/mysql/my.cnf
补充:
启动脚本:
./script/mysql_install_db --user=admin --basedir=/home/admin/jyp/mysql --datadir=/home/admin/jyp/mysql/data
./bin/mysqld_safe --user=admin --basedir=/home/admin/jyp/mysql --datadir=/home/admin/jyp/mysql/data