日期:2014-05-16  浏览次数:20655 次

linux上安装mysql-ok
从官网下载源码安装包

mysql-5.0.22.tar.gz
可参考http://wenku.baidu.com/view/9d20c63d0912a21614792942.html




需要先装好gcc




安装



# groupadd mysql
# useradd -g mysql mysql

?解压编译



# tar -zxvf mysql-5.0.22.tar.gz
# cd mysql-5.0.22
# ./configure --prefix=/usr/local/mysql --with-charset=gbk
# make
# make install
# cp support-files/my-medium.cnf /etc/my.cnf

设置自启动



# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
# chmod 700 /etc/rc.d/init.d/mysqld
# chkconfig --add mysqld
# chkconfig --level 345 mysqld on

数据库初始化



# cd /usr/local/mysql
# /usr/local/mysql/bin/mysql_install_db --user=mysql
# chown -R root .(注意有个.)




# chown -R mysql var
# chgrp -R mysql .(注意有个.)




# /usr/local/mysql/bin/mysqld_safe --user=mysql &


启动数据库 建立快捷方式



# /etc/rc.d/init.d/mysqld start

# ln -s /usr/local/mysql/bin/mysql /sbin/mysql
# ln -s /usr/local/mysql/bin/mysqladmin /sbin/mysqladmin

# PATH=$PATH:/usr/local/mysql/bin
# export PATH
# echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
# ldconfig

重启



#reboot









给root加个密码123456。



键入以下命令 :
#/usr/local/mysql/bin/mysqladmin  -u root password 123456

测试数据库



#mysql -u root -p123456
出现
mysql>

安装成功!


Linux mysql 允许远程连接





#mysql -u root -p123456
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema | 
| mysql              | 
| test               | 
| uportal            | 
+--------------------+
4 rows in set (0.08 sec)

mysql> use mysql;
Database changed

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;