mysql安装(源码编译安装)
1 安装mysql
#makedir -p /usr/local/mysql
#./configure --prefix=/usr/local/mysql
#make
#make install
./configure 出现错误的时候
1)
checking for termcap functions library… configure: error: No curses/termcap library found
解决办法:
# rpm -ivh ncurses-devel-5.7-3.20090208.el6.i686.rpm
Making install in win
出现这个则说明安装成功
2 建立mysql用户
#useradd -s /sbin/nologin mysql
3 相关配置
#cd /usr/local/mysql
#bin/mysql_install_db --user=mysql
#mkdir -p /var/mysql
#cp share/mysql/mysql.server /etc/init.d/mysqld
#chkconfig --add mysqld
#service mysqld start //启动服务
#vim /etc/profile 在最后一行加入
export PATH=$PATH:/usr/local/mysql/bin
#source /etc/profile
4 客户端访问mysql
#mysql
如果出现
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)
1.直接指定mysql通道
# mysql --socket=/var/lib/mysql/mysql.sock
# mysql
Welcome to the MySQL monitor. Commands end with ; or /g.
Your MySQL connection id is 2 to server version: 5.0.22
Type ‘help;’ or ‘/h’ for help. Type ‘/c’ to clear the buffer.
mysql>
- 创建符号连接:
为mysql.sock增加软连接(相当于windows中的快捷方式)。
# ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
# mysql
eg:
root@localhost ~]# mysql
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)
[root@localhost ~]# ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
[root@localhost ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or /g.
Your MySQL connection id is 3 to server version: 5.0.22
Type ‘help;’ or ‘/h’ for help. Type ‘/c’ to clear the buffer.
mysql>
5 root添加密码
#mysqladmin -uroot password root
再次登录
#mysql -hlocalhost -uroot -proot