1. mysql 安装 yum -y install mysql-server yum -y install php-mysql vi /etc/my.cnf [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 default-character-set=utf8 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid chkconfig mysqld on chkconfig --list mysqld /etc/rc.d/init.d/mysqld start 初始化mysql mysqladmin -u root -p password delete from mysql.user where user=''; 删除匿名用户 flush privileges; ← 刷新,使以上操作生效 2. 连接mysql mysql -h 主机地址 -u 用户名 -p 用户密码 mysql -h110.110.110.110 -uroot -pabcd123(注:u与root可以不用加空格,其它也一样) mysql -uroot -p; mysql -uroot -pnewpassword; mysql mydb -uroot -p; mysql mydb -uroot -pnewp3. 账户设置 use mysql; delete from User where User=""; update User set Password=PASSWORD('pass') where User='root';4. 添加账户 向user表中添加数据 使用grant grant all on mydb.* to [email protected] identified by "password" ; grant usage on *.* to [email protected] identified by "password"; grant select,insert,update on mydb.* to [email protected] identified by "password"; grant update,delete on mydb.TestTable to [email protected] identified by "password"; 全局管理权限: FILE: 在MySQL服务器上读写文件。 PROCESS: 显示或杀死属于其它用户的服务线程。 RELOAD: 重载访问控制表,刷新日志等。 SHUTDOWN: 关闭MySQL服务。 数据库/数据表/数据列权限: Alter: 修改已存在的数据表(例如增加/删除列)和索引。 Create: 建立新的数据库或数据表。 Delete: 删除表的记录。 Drop: 删除数据表或数据库。 INDEX: 建立或删除索引。 Insert: 增加表的记录。 Select: 显示/搜索表的记录。 Update: 修改表中已存在的记录。 特别的权限: ALL: 允许做任何事(和root一样)。 USAGE: 只允许登录--其它什么也不允许做。5. 更改密码 mysqladmin -u 用户名 -p 旧密码 password 新密码 mysqladmin -uroot -password ab12 注:因为开始时root没有密码,所以-p旧密码一项就可以省略了。 6. 备份数据库 mysqldump --opt school>school.bbb 导出整个数据库 mysqldump -u 用户名 -p --default-character-set=latin1 数据库名 > 导出的文件名(数据库默认编码是latin1) mysqldump -u wcnc -p smgp_apps_wcnc > wcnc.sql 导出一个表 mysqldump -u 用户名 -p 数据库名 表名> 导出的文件名 mysqldump -u wcnc -p smgp_apps_wcnc users> wcnc_users.sql 导出一个数据库结构 mysqldump -u wcnc -p -d –add-drop-table smgp_apps_wcnc >d:wcnc_db.sql -d 没有数据 –add-drop-table 在每个create语句之前增加一个drop table 导入数据库 常用source 命令 进入mysql数据库控制台, 如mysql -u root -p mysql>use 数据库 然后使用source命令,后面参数为脚本文件(如这里用到的.sql) mysql>source wcnc_db.sql 使用mysqldump命令 mysqldump -u username -p dbname < filename.sql 使用mysql命令 mysql -u username -p -D dbname < filename.sql 7. 更改表名: 命令:rename table 原表名 to 新表名; 例如:在表MyClass名字更改为YouClass mysql> rename table MyClass to YouClass;
详细解决方案
mysql惯用管理命令
热度:344 发布时间:2016-05-05 16:22:50.0
相关解决方案
- mysql 简单化 or能否实现
- 请问registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister
- MySQL 5.5 Command Line Client 窗口1输密码就退出
- 请问上Linux平台上怎么搭建JDK \TOMCAT\MYSQL
- 在LINUX上配置 MySQL 开机自动 启动
- mysql 转 orocle java ssh项目一条 sql 句不通!
- 急求帮忙!mysql 【 Column count doesn't match value count 】,该怎么解决
- jsp中的注册登录系统(mysql)
- 上了个 MySQL 5.5.25 但是安装时出错了
- 求jsp博客源代码mvc+mysql,该如何解决
- java mysql 中文乱码有关问题
- 请教各位,使用PreparedStatement mysql 数据库 不回滚,盼望解答。多谢。 具体如上
- mysql Statement parameter 一 not set
- java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306,该怎么处理
- MyBatis 读取 Mysql Blob类型的SQL如何写呢
- JDBC MYSQL 驱动加载失败 JSP DAO ECLIPSE,该怎么解决
- Only a type can be imported. com.mysql.jdbc.Driver resolves to a package解决方案
- tomcat 中抛异com.mysql.jdbc.exceptions.MySQLTransactionRollbackException,该如何处理
- struts+iBatis+mysql,该如何解决
- mysql 有外键的插入解决方案
- JSP 更新 MySQL 语句时遇到异常了= =
- mysql,该如何处理
- +++++ mysql 插入成功,查询不到记录?
- MyBatis3.1.1 Insert 回到主键 long类型 MYSQL 数据库
- mysql:假若一个表中,有两个属性name和id,删除同名的保留id小的,问这样写有误吗
- java mysql where限制有关问题
- mysql 数据库,如果信息存在调出,如果不存在转到另一个jsp中解决思路
- mysql jdbc的配置解决方案
- java.lang.ClassNotFoundException:com.mysql.jdbc.Driver,该如何解决
- 救助。Mysql 的条件删除语句如何写,就是删除部门的时候,如果部门下有用户,就不能删除