1 mysql实战二进制安装
数据库和web分离,web服务器上如何安装mysql?
通过mysql的包,调用Php的函数,make install后即可。
useradd mysql -s /sbin/nologin �CM
tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz
mv mysql-5.5.32-linux2.6-x86_64/ /application/mysql-5.5.32/
ln -s /application/ mysql-5.5 /application/mysql
mkdir /application/mysql/data
chown -R mysql.mysql /application/mysql/data/
chmod -R 1777 /tmp/ 调整/tmp权限,否则初始化会错误
[root@hexudong mysql]# ./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql
初始化数据库
when specifying MySQL privileges !
Installing MySQL system tables...
OK
Filling help tables...
OK 出现两个OK 代表成功
[root@hexudong mysql]# cp support-files/my-small.cnf /etc/my.cnf
cp: overwrite `/etc/my.cnf'? y
更改/etc/init.d/mysqld 文件
46 basedir=/application/mysql
47 datadir=/application/mysql/data
echo "export PATH=/application/mysql/bin:$PATH" >>/etc/profile
source /etc/profile
Data 里面的库
performance_schema mysql 自己的维护的库
mysql 用户权限等库
二进制安装,默认为/usr/local 路径,要更改配置文件里的路径。
出现的问题解决:
[root@mysql1 scripts]# ./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql
FATAL ERROR: Could not find my_print_defaults
The following directories were searched:
/application/mysql//bin
/application/mysql//extra
If you compiled from source, you need to run 'make install' to
copy the software into the correct location ready for operation.
If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.
[root@mysql1 scripts]# ./mysql_install_db --basedir=/application/mysql-5.5.32/ --datadir=/application/mysql-5.5.32/data/ --user=mysql
安装路径不正确!!!!
mysql报错解决
[root@hexudong mysql]# /etc/init.d/mysqld start
Starting MySQL... ERROR! The server quit without updating PID file (/var/lib/mysql/hexudong.oldboy.pid).
[root@hexudong mysql]# killall mysqld
多killall 几次即可。
问题一:(李新宇)
[root@c66-kslx mysql]# /etc/init.d/mysqld start
Starting MySQL... ERROR! The server quit without updating PID file (/var/lib/mysql/c66-kslx.pid).
问题原因:权限问题,没有授权MySQL管理数据库文件
解决方法:
chown -R mysql.mysql /application/mysql/
问题二:(肖海波)
ERROR: 1 Can't create/write to file '/tmp/#sql_6a81_0.MYI' (Errcode: 13)
问题原因:权限问题
解决方法:chmod -R 1777 /tmp
问题三:mysql包传送有问题
解决方法:rz 不要打勾。ASCII
问题四:(卢世祺)
[root@TraumLou application]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
问题原因:初始化问题
解决方法:删除data目录重建,重新初始化
问题五:(断翅)
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
问题原因:服务没启动
mkdir /data/{3306,3307}/data -p
把data 文件,放到跟下解压。
/application/mysql/scripts/mysql_install_db --basedir=/application/mysql --datadir=/data/3306/data/ --user=mysql
初始化第一个实例
./mysql_install_db --basedir=/application/mysql/ --datadir=/data/3307/data/ --user=mysql
初始化第二个实例
授予执行权限
[root@mysql1 scripts]# find /data -type f -name mysql | xargs ls
/data/3306/mysql /data/3307/mysql
[root@mysql1 scripts]# find /data -type f -name mysql | xargs chmod +x
授予myssql权限
chown mysql.mysql -R /data
关闭数据库:
/mysqladmin -u ${mysql_user} -p${mysql_pwd} -S /data/${port}/mysql.sock shutdown
启动数据库:
mysql -uroot -p3306 -S /data/3306/mysql.sock
本文出自 “晴空” 博客,谢绝转载!