刚接触linux在linux下安装mysql,由于之前没有经验绕了好久,现在说几个我在安装中遇到的问题:
# rpm -qa|grep -i mysql
b.如有就会显示:
MySQL-client-5.5.25-1.rhel5
MySQL-server-5.5.25-1.rhel5
c.有就删除:(先删除client 再删server)
# rpm -ivh MySQL-server-5.5.25-1.rhel5.x86_64.rpm
如果成功会显示
Preparing... ########################################### [100%]
1:MySQL-server ########################################### [100%]
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h eBSM-Server2 password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
Please report any problems with the /usr/bin/mysqlbug script!
# rpm -ivh MySQL-client-5.5.25-1.rhel5.x86_64.rpm
成功显示:
Preparing... ########################################### [100%]
1:MySQL-client ########################################### [100%]
# service mysql start
Starting MySQL.. [ OK ]
[root@eBSM-Server2 init.d]# service mysql start
Starting MySQL...The server quit without updating PID file (/var/lib/mysql/eBSM-Server2.pid). [FAILED]
解决方法:
1.mv /var/lib/mysql /data,把安装目录就放到/data/mysql下了。
赋值权限:
chmod 777 -R /data/mysql/
2./etc/rc.d/init.d/mysql 修改数据文件路径为datadir=/data/mysql
3.拷贝配置文件到/etc目录下,并命名为my.cnf(必须名为my.cnf)
cp/usr/share/mysql/my-medium.cnf /etc/my.cnf
注意:/usr/share/mysql/下有好几个结尾为cnf的文件,它们的作用分别是:
1.my-small.cnf是为了小型数据库而设计的。不应该把这个模型用于含有一些常用项目的数据库。 RAM需求(256MB)明显多得多的物理内存。由此可见,如果有那么多RAM内存可以使用,自然可以在同一台机器上运行其它服务。 所以在这种类型的系统上将需要至少1GB的RAM,以便它能够同时处理操作系统与数据库应用程序。 并访问数据的用户数量。随着数据库和用户的不断增加,数据库的性能可能会发生变化。 |
[client]
password = root
port = 3306
socket = /data/mysql/mysql.sock
default-character-set=utf8
[mysqld]
port = 3306
socket = /data/mysql/mysql.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
character_set_server=utf8
collation-server=utf8_general_ci
lower_case_table_names=1
character_set_client=utf8
[mysql]
default-character-set = utf8
no-auto-rehash
[root@eBSM-Server2 /]# mysql -h localhost -u root
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
上面这一行是设置远程连接为任意IP没设密码的,按自己需求定.
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
退出:
mysql> EXIT;
Bye
最后说一句,这个报错情况看个人而定的,不是每一次报错都是同一种解决方法,