提示:本文操做环境是MariaDB 和Sqlite3。mysql
本文测试环境Sqlite3 安装文件位于 D:\sqlite-tools-win32-x86-3230100 目录。sql
Sqlite3 建立数据库hello.db.数据库
命令行下输入(hello.db是实例数据库名称)测试
#切换到sqlite3可执行文件目录D盘 C:\Users\test>D: D:\>cd sqlite-tools-win32-x86-3230100 D:\sqlite-tools-win32-x86-3230100>sqlite3 SQLite version 3.23.1 2018-04-10 17:39:29 Enter ".help" for usage hints. Connected to a transient in-memory database. Use ".open FILENAME" to reopen on a persistent database. sqlite> .quit #建立hello.db数据库 D:\sqlite-tools-win32-x86-3230100>sqlite3 hello.db SQLite version 3.23.1 2018-04-10 17:39:29 Enter ".help" for usage hints. sqlite> #注:本地文件须要在建立表或sqlite3退出后生成本地文件。
命令完成同时进入数据库控制台界面。 ui
.databases命令查看数据库信息,本文数据库文件位于C:\Users\Administrator\hello.db。命令行
.databases
建立表A。code
create table A(id,name);
根据命令可知sqlite3建立表能够不指定数据类型。固然,语句结束须要有分号,并最好可以在同一行。sqlite
查看表。进程
.tables
Linux MySQL 远程访问控制。图片
sudo -i切换到root帐号,输入命令mysql。
切换到mysql数据库。
mysql>update user set host='172.20.0.0/24' where user='root';
增长172.20.0.0网段访问权限。host能够是网段,主机名或者IP地址。
mysql>select host,user from user;
查询主机和用户权限设置。
mysql>flush privileges;
刷新用户权限。
root@jiangjuan-OptiPlex-390:~# mysql ERROR 1698 (28000): Access denied for user 'root'@'localhost'
随意修改权限可能致使没法本地访问数据库。解决该问题方法以下。 首先中止数据库服务。
/etc/init.d/mysql stop
本文还涉及到杀死mysql进程问题。 首先经过ps -aux 命令找到mysql 进程ID,本文是12914(1286),请根据实际状况选择。
kill -s 9 12914 kill -s 9 1286
mysql>mysqld_safe –skip-grant-tables & mysql>mysql
跳过验证过程,从新登陆。
mysql>use mysql mysql>select user,host,password from user where user='root';
查询结果未显示localhost能够登录。
mysql>update user set host='localhost' where user='root' and host='%'; mysql>flush privileges;
从新受权并重启MySQL服务便可。
mysql>mysql -u root –p mysql>use mysql; mysql>update user set host = '%' where user = 'root'; mysql>select host, user from user;
该方法也能够设置任意机器访问数据库。