MySql & python

Today I want to build a database for storing my records data.
My developing environment is ubuntu 18.04

Before the developing

  1. Install MySql on ubuntu. So mysql is seen as a server service on my ubuntu, to install it with sudo apt-get install mysql-server
  2. After installed, use sudo netstat -tap | grep mysqlto check if sql service is listening.
  3. After verified, use default user root to login sudo mysqlor more specific sudo mysql -h localhost -P 3306 -uroot -ppasswdto login the server. Mysql has stored all the user info in the tables. Use show tables from mysql; to check.
  4. After login, show databases;(always use databases with ;, mysql would not think the command is ended unless ; is put ) to get the list of all the databases generated by default.
  5. If a new user is needed or existing user needs to be changed, to use create user <u_name>@<u_host> identified by 'password'; or alter user ... identified with mysql_native_password by '<new_password>'; The latter could also be used to alter the verification methods for authentication methods for mysql account.

Developing

  1. Create a database: create database/create schema [name];: create one database with name, this database has no tables.
  2. Add tables to an existing database: use [dbname];: Tells mysql to use daname database as the current database for subsequent statements. Then create table <t_name> (<row_name> type); . Now an empty table should be created.
  3. Insert values to the tables insert into <t_table>(<row_name>) values(val); then select <row_name> from <t_table>; to retrieve a column back.

Questions

  1. Privilege: I have encountered this many times reading \h <item> , what is this and how would this be changed? where is this stored?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值