安装mysql时候找不到密码尝试无果后开始卸载重装
create database testdb;
create user 'testuser'@'localhost' identified by 'password';
grant all on testdb.* to 'testuser' identified by 'password';
yum update -y 不用按确定一直跟新的
rpm -e 软件包:卸载软件包
rpm -e --nodeps:强制卸载
查看mysql的安装情况
rpm -qa | grep -i mysq
卸载:
1.普通卸载(可能有依赖关系)
rpm -e mysql-community-libs-5.7.18-1.el6.x86_64
2.强制卸载
rpm -e --nodeps mysql-community-libs-5.7.18-1.el6.x86_64
删除mysql服务
[root@localhost
local]# chkconfig --list | grep -i mysql
[root@localhost local]# chkconfig --del mysql
删除分散mysql文件夹
[root@localhost local]# whereis mysql 或者 find / -name mysql
mysql: /usr/lib/mysql /usr/share/mysql
清空相关mysql的所有目录以及文件
rm -rf /usr/lib/mysql
rm -rf /usr/share/mysql
rm -rf /usr/my.cnf
下面成功安装mysql服务详细步骤
1.Update your system:
sudo yum update2.Install and Start MySQL
(1)Install MySQL and tell it which runlevels to start on:
sudo yum install mysql-server sudo /sbin/chkconfig --levels 235 mysqld on(2)Then to start the MySQL server:
sudo service mysqld start3.set password
sudo mysql_secure_installation回车,回车跳过初始密码
设置新的密码
4.登录mysql
mysql -u root -p
Create a New MySQL User and Database
-
In the example below,
testdbis the name of the database,testuseris the user, andpasswordis the user’s password.create database testdb; create user 'testuser'@'localhost' identified by 'password'; grant all on testdb.* to 'testuser' identified by 'password';
You can shorten this process by creating the user while assigning database permissions:
-
create database testdb; grant all on testdb.* to 'testuser' identified by 'password';
-
Then exit MySQL.
-
Create a Sample Table
mysql -u testuser -p
重置密码:
If you forget your root MySQL password, it can be flushed and then reset.
-
Stop the current MySQL server instance, then restart it with an option to not ask for a password.
sudo /etc/init.d/mysqld stop sudo mysqld_safe --skip-grant-tables &Reconnect to the MySQL server with the MySQL root account.
mysql -u root
Use the following commands to reset root’s password.
Replace password with
a strong password.
use mysql;
update user SET PASSWORD=PASSWORD("password") WHERE USER='root';
flush privileges;
exit
Then restart MySQL.
sudo service mysqld restart
关于数据库乱码问题:
查看数据库字符集
SHOW VARIABLES LIKE 'character%';
上面是正确的编码
刚开始可能是latint1,全部修改成你需要的编码
#vim /etc/mysql/my.cnf (5.5以前系统)如下修改:
在【client】下面加入 default-character-set=utf8
在【mysqld】下面加入default-character-set=utf8
Notice:注意 如果修改后不能启动报错试试把default-character-set=utf8改为character_set_server=utf8,仅仅加入到mysqld下面的.client就不需要加了
#vim /etc/mysql/my.cnf 。(5.5以后系统)如下修改:
[client]
default-character-set=utf8
[mysqld]
default-storage-engine=INNODB
character-set-server=utf8
collation-server=utf8_general_ci
卸载:参考:http://blog.youkuaiyun.com/rosten/article/details/25096159
安装:参考:https://www.linode.com/docs/databases/mysql/how-to-install-mysql-on-centos-6
本文详细介绍MySQL的安装步骤、配置过程及解决常见问题的方法,包括如何创建数据库和用户、设置密码及处理乱码问题。
2万+

被折叠的 条评论
为什么被折叠?



