Mysql
跳到导航
跳到搜索
- 安装和启动mysql服务
- yum install mysql
- service mysqld start
- service enable mysqld (开机启动)
- 设置mysql的root用户
- mysqladmin -uroot -p password 'newpassword'
- 这种情况有时会报错,网上给出的方法是
# /etc/init.d/mysql stop # mysqld_safe --user=mysql --skip-grant-tables --skip-networking & # mysql -u root mysql mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root'; mysql> FLUSH PRIVILEGES; mysql> quit
- 建立某个数据库db1
- mysql -u root -p
- password:***
- mysql>create database db1;
- mysql>grant all on db1.* to dbuser@localhost identified by 'password'; (建立一个dbuser的数据库用户)
- mysql>exit
- 测试dbuser
- mysql -u dbuser -p
- 导入备份数据库
- mysql -u root -p db1 < "data base backup file"
- 备份数据库
- mysqldump -u root -p 'pasword' db1 | gzip > /bak/db1.bakup.gz