1、安装html
经过使用sudo apt-get install mysql-server安装库中最新版本的mysqlmysql
安装好以后,使用mysql -u root -p进入mysql时报错。sql
经过在/etc/mysql/mysql.conf目录下的mysqld.cnf文件中增长skip-grant-tables,以便在登陆时能够无需密码进入mysql数据库
修改后须要使用service mysql restart命令来重启mysql服务,使得刚刚添加的属性生效url
使用use mysql;.net
使用select user, plugin, authentication_string from user;来查询用户中的有关信息3d
经过使用update user set authentication_string=password("mysqlmysql"), plugin='mysql_native_password' where user='root';来更新表中相关信息。rest
感谢如下博客博文对本节的帮助。server
https://www.cnblogs.com/cpl9412290130/p/9583868.htmlhtm
2、经常使用数据库操做
show databases 展现全部数据库
select database(); 表示当前所使用的数据库,若进入数据库没有使用use命令切换至某数据库,则当前查询为NULL。
经过使用creat database 数据库名 charset=utf8; 来建立相应数据库名的数据库。
并使用use 数据库名; 来切换到对应的数据库。
经过下图能够知道,即时使用use切换到某数据库,也能执行create database 数据库名 charset=utf8; show databases; drop database 数据库名;
drop database 数据库名; 删除对应数据库名的数据库。
使用use 数据库名切换到对应数据库后,就能够进行表操做了。
使用show tables; 展现全部表
经过create table 表名(字段1 类型 约束,字段2 类型 约束,...); 建立表
使用desc 表名; 展现表的详细信息
经过insert into 表名 values(全字段), (全字段),...; 将数据添加进表中
经过alter table 表名 add/change/drop 字段名 约束; 进行相应的字段增删改操做
可经过insert into 表名 (指定字段名) value (指定字段名对应的值),...; 将新数据添加进表中
经过select * from 表名; 查询表中全部数据
经过select 字段1,... from 表名; 查询表中特定字段数据
感谢如下博客博文对本节的帮助
https://www.cnblogs.com/summer1019/p/11015212.html
https://blog.csdn.net/doubleicefire/article/details/80544516