标签:block varchar 取出 word 设置 mysql用户 建表 lin http
Mysql比较轻量化,企业用的是Oracle,基本的是熟悉对数据库,数据表,字段,记录的更新与修改
连接:mysql -u username -h [ip] -p [password]
增加用户:
root@host# mysql -u root -p
Enter password:*******
mysql> use mysql;
Database changed
mysql> INSERT INTO user
(host, user, password,
select_priv, insert_priv, update_priv)
VALUES (‘localhost‘, ‘guest‘,
PASSWORD(‘guest123‘), ‘Y‘, ‘Y‘, ‘Y‘);
Query OK, 1 row affected (0.20 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 1 row affected (0.01 sec)
mysql> SELECT host, user, password FROM user WHERE user = ‘guest‘;
+-----------+---------+------------------+
| host | user | password |
+-----------+---------+------------------+
| localhost | guest | 6f8c114b58f2ce9e |
+-----------+---------+------------------+
1 row in set (0.00 sec)
root@host# mysql -u root -p password;
Enter password:*******
mysql> use mysql;
Database changed
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
-> ON TUTORIALS.* //数据库TUTORIALS下任意表
-> TO ‘zara‘@‘localhost‘
-> IDENTIFIED BY ‘zara123‘;
以上命令会在mysql数据库中的user表创建一条用户信息记录
初始修改密码:mysqladmin -u root password "new_password";
数据库的创建:create database_name;
数据表的创建:熟悉内置的数据类型与修饰符
mysql> CREATE TABLE jser_tbl(
-> jser_id INT NOT NULL AUTO_INCREMENT,
-> jser_title VARCHAR(100) NOT NULL,
-> jser_author VARCHAR(40) NOT NULL,
-> submission_date DATE,
-> PRIMARY KEY ( jser_id )
-> );
Query OK, 0 rows affected (0.16 sec)
INSERT INTO table_name ( field1, field2,...fieldN )
VALUES
( value1, value2,...valueN );
select * from table_name where id=‘$id‘ and username=‘$user‘;
select column_name,... from tabl_name oreder by column_name;
SELECT field1, field2,...fieldN table_name1, table_name2...
[WHERE Clause]
[OFFSET M ][LIMIT N];//设置指针跳的长度,取出记录个数
SELECT field1, field2,...fieldN table_name1, table_name2...
ORDER BY field1, [field2...] [ASC [DESC]];//排序
UPDATE table_name SET field1=new-value1, field2=new-value2
[WHERE Clause];
update table_name set field1=field1+|-num where [options];
delete from table_name where [options];
ALTER TABLE testalter_tbl DROP i;
使用 ADD 子句来想数据表中添加列,如下实例在表 testalter_tbl 中添加 i 字段,并定义数据类型:
ALTER TABLE testalter_tbl ADD i INT;
把字段 c 的类型从 CHAR(1) 改为 CHAR(10),可以执行以下命令:
ALTER TABLE testalter_tbl MODIFY c CHAR(10);
show databases;
use databases;
show tables;
desc table)name;
connection mysql_connect(server,user,passwd,new_link,client_flag);//返回一个连接句柄
$link = mysqli_connect("localhost","root","");
if($link){
echo "success";
}
mysqli_query($link,"set name utf8");
mysqli_select_db($link,$database);
标签:block varchar 取出 word 设置 mysql用户 建表 lin http
原文地址:https://www.cnblogs.com/0xthonsun/p/9876095.html