CentOS上mysql-server的安装指南(Linux安装mysql实战指南)
一:yum 方式安装[root@systdt mysql]# cat /etc/issue
CentOS release 6.4 (Final)Kernel \r on an \m
[op1@VMS06968 ~]$ yum list mysql*Loaded plugins: downloadonly, fastestmirror, securityDetermining fastest mirrorsInstalled PackagesMySQL-client.x86_64 5.6.21-1.el6 @custommysql-libs.x86_64 5.1.66-2.el6_3 @anaconda-CentOS-201303020151.x86_64/6.4Available PackagesMySQL-devel.x86_64 5.6.21-1.el6 customMySQL-python.x86_64 1.2.3-0.3.c1.1.el6 baseMySQL-server.x86_64 5.6.21-1.el6 custom##安装server端[op1@VMS06968 ~]$ yum install mysql-server
#安装client端[op1@VMS06968 ~]$ yum install mysql
如果安装的过程中报错,删除mysql相关lib,命令如下:;然后再执行上述安装的两个步骤;[op1@VMS06968 ~]$ yum remove mysql*
2.2、配置文件 /usr/share/mysql(mysql.server命令及配置文件)
2.3、相关命令 /usr/bin(mysqladmin mysqldump等命令)
2.4.1、启动脚本1 /etc/rc.d/init.d/mysql(启动脚本文件mysql的目录)2.4.2、启动脚本2 /etc/init.d/mysql(启动脚本文件mysql的目录)
[root@systdt mysql]# vi /usr/my.cnf# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html[client]no-beepbind-address = 0.0.0.0port=3306
[mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockcharacter-set-server=utf8sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLESdefault-storage-engine=INNODB #默认数据储存格式max_connections=10innodb_buffer_pool_size=256M #内存query_cache_size=30M
[mysql]default-character-set = utf8
[root@systdt mysql]#mysqladmin -u root password ‘root‘ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO)
1、停用mysql服务:# /etc/rc.d/init.d/mysqld stop2、输入命令:# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &3、登入数据库:# mysql -u root mysql4、mysql> use mysql;mysql> UPDATE user SET Password=PASSWORD(‘root‘)where USER=‘root‘;mysql> FLUSH PRIVILEGES;mysql> quit5、重启服务:# /etc/init.d/mysql restart如果用新用户名,密码登陆进去报错如下:
mysql> show databases;ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
# chkconfig mysqld on ← 设置MySQL服务随系统启动自启动
# chkconfig –list mysqld ← 确认MySQL自启动mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off ← 如果2–5为on的状态就OK
#service mysqld start ←启动服务(# /etc/rc.d/init.d/mysqld start也可以)
delete from mysql.user where user=”; ← 删除匿名用户select user,host from mysql.user; ← 查看用户信息
select version(),current_date; #当前版本信息,日期和数据库:show databases; ← 查看系统已存在的数据库drop database test; ← 删除名为test的空数据库
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。