8种机械键盘轴体对比
本人程序员,要买一个写代码的键盘,请问红轴和茶轴怎么选?
安装MariaDB
MariaDB是MySQL的一个分支
直接命令行敲入:1sudo apt-get install mariadb-server
即可完成安装。
一开始安装完成后不知道是需要初始化,折腾了半天登录不了,改不了密码。后来才知道,安装完成后需要立刻的命令行敲入:
mysql_secure_installation
然后会引导进行初始化操作。
一切正常之后,发现程序如果是非root用户权限下运行的程序,无法连接上数据库。
包括直接命令行输入:1mysql -u root -p
登录发现也被拒绝登录了。显示’Access denied for user [email protected] (using password: YES)’
必须用root权限1sudo mysql -u root -p
才能登录成功。
登录成功后进行如下命令修改:1
2
3update mysql.user set plugin='mysql_native_password' where user='root';
update mysql.user set password=password("您要修改的密码") where user='root';
FLUSH PRIVILEGES;
最后终于和普通MySQL一样的使用了。
然后需要进行远程连接数据库访问的话,敲入:1grant all on *.* 'root'@'%' identified by '123456';
注:by后面是密码。
远程登录设置
1、连接服务器: mysql -u root -p
2、看当前所有数据库:show databases;
3、进入mysql数据库:use mysql;
4、查看mysql数据库中所有的表:show tables;
5、查看user表中的数据:select Host, User,Password from user;
6、修改user表中的Host:update user set Host=’%’ where User=’root’;
7、最后刷新一下:flush privileges;
python连接MariaDB1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#!/usr/bin/python
#coding=utf8
import pymysql
#连接数据库,host、账号、密码、库
db = pymysql.connect('192.168.2.1','root','123456','testdb')
#创建游标使用的cursor方法
cursor = db.cursor()
#使用execute方法执行sql语句
cursor.execute('select version()')
#使用fetchone方法获取单条数据
data = cursor.fetchone()
print('Database version:%s' % data)
#关闭游标,并关闭数据库
cursor.close()
db.close()