CentOS 5/6 使用YUM安装MySQL 5.5
==============================
最简单明了的方式安装MYSQL 5.5
1.使用 Webtatic YUM 源
对于 CentOS/RHEL 6.x
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
对于 CentOS/RHEL 5.x
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-5.noarch.rpm
rpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpm
已经安装了早前版本,升级
~~~
If you already have MySql client or server installed (rpm -q mysql mysql-server), then you can upgrade using the following method:
yum install mysql.`uname -i` yum-plugin-replace
yum replace mysql --replace-with mysql55w
“yum install mysql” is only there to make sure yum-plugin-replace can resolve dependencies correctly if only mysql-server was installed.
~~~
全新安装MySQL 5.5
yum install mysql55w mysql55w-server
You should upgrade existing tables before setting the server to become a production machine, which can be done by starting the server and running the mysql_upgrade script (this may take time depending on the size of the database).
service mysqld start
This will issue a password prompt for the user. If you don't have a root user password, remove the "-p"
mysql_upgrade -u root -p
----
安装完成后安全配置
--
mysql_secure_installation
2、启动、停止设置
--
数据库字符集设置
mysql配置文件/etc/my.cnf中加入
default-character-set=utf8
启动mysql服务:
service mysqld start
或者/etc/init.d/mysqld start
设置开机启动:
chkconfig -add mysqld
查看开机启动设置是否成功
chkconfig --list | grep mysql*
mysqld 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
停止mysql服务:
service mysqld stop
3、登录及忘记修改密码
创建root管理员:
mysqladmin -u root password 666666
登录:
mysql -u root -p
如果忘记密码,则执行以下代码
~~~
service mysqld stop
mysqld_safe --user=root --skip-grant-tables
mysql -u root
use mysql
update user set password=password("666666") where user="root";
flush privileges;
~~~
4、允许远程访问设置
开放防火墙的端口号
mysql增加权限:mysql库中的user表新增一条记录host为“%”,user为“root”。
use mysql;
UPDATE user SET `Host` = '%' WHERE `User` = 'root' LIMIT 1;
%表示允许所有的ip访问
5、mysql的几个重要目录
(a)数据库目录
/var/lib/mysql/
(b)配置文件
/usr/share /mysql(mysql.server命令及配置文件)
(c)相关命令
/usr/bin(mysqladmin mysqldump等命令)
(d)启动脚本
/etc/rc.d/init.d/(启动脚本文件mysql的目录)
---
附:此台服务器的my.cnf配置
skip-locking
skip-name-resolve
key_buffer = 1024M
back_log = 3000
max_allowed_packet = 4M
table_cache = 512
sort_buffer_size = 8M
read_buffer_size = 8M
myisam_sort_buffer_size = 1024M
thread_cache = 512
query_cache_size = 512M
set-variable = wait_timeout=60
thread_concurrency = 4
log-slow-queries = slow.log
long_query_time = 1
innodb_flush_log_at_trx_commit = 2
innodb_buffer_pool_size = 1024M
#innodb_locks_unsafe_for_binlog = 1
如果不是升级,而是新安装。还需要设置root密码,删除默认的空用户、空密码等等........
- 0 综合性知识库
- 1 前端资源
- 2 电子书籍和搜索工具
- 3 数据库
- 3.1 MySQL工具
- 3.2 YUM安装MySQL 5.5
- 3.3 MySQL升级
- 3.4 MySQL主从复制
- 3.5 Lepus数据库监控工具
- 4 应用服务器
- 4.1 Apache
- 4.2 Ngnix
- 4.3 Kangle
- 4.4 各种一键包
- 4.5 应用服务器APP API
- 5 语言和脚本工具
- 5.1 安装PHP多版本
- 5.2 YUM升级PHP5.6
- 5.2 Python升级2.7
- 5 MarkDown
- 6 Git
- 7 云计算VPS供应商
- 700 服务器Linux技术
- 7.1 服务器查找工具
- 701 服务器可视化技术
- 800 发布相关素材
- 997 模板类内容
- 9971 翻译模板一
