赞
踩
[root@mysql ~]# yum -y install wget
[root@mysql ~]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.33-1.el7.x86_64.rpm-bundle.tar
[root@mysql ~]# tar -xf mysql-8.0.33-1.el7.x86_64.rpm-bundle.tar
[root@mysql ~]# rpm -e --nodeps mariadb-libs
[root@mysql ~]# rpm -ivh mysql-community-common-8.0.33-1.el7.x86_64.rpm
[root@mysql ~]# rpm -ivh mysql-community-client-plugins-8.0.33-1.el7.x86_64.rpm[root@mysql ~]# rpm -ivh mysql-community-libs-8.0.33-1.el7.x86_64.rpm
[root@mysql ~]# rpm -ivh mysql-community-client-8.0.33-1.el7.x86_64.rpm
[root@mysql ~]# rpm -ivh mysql-community-icu-data-files-8.0.33-1.el7.x86_64.rpm[root@mysql ~]# rpm -ivh mysql-community-server-8.0.33-1.el7.x86_64.rpm
[root@mysql ~]# mysqld --initialize --console
[root@mysql ~]# chown -R mysql:mysql /var/lib/mysql/
[root@mysql ~]# systemctl start mysqld
[root@mysql ~]# cat /var/log/mysqld.log | grep localhost
2024-08-02T01:49:19.435048Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: dQ1o<YO&YNyX 密码
[root@mysql ~]# mysql -uroot -p
Enter password: 密码mysql>
mysql> alter user 'root'@'localhost'identified by '123456';
Query OK, 0 rows affected (0.01 sec)
[root@mysql ~]# mysql -uroot -p123456mysql> quit
Bye
1. 数据库系统 DBMS
2. 数据库 DB
3. 表 table
4. 记录 record
5. 字段 feild
语法:create table user( id int primarykey,username varchar,password varchar );
mysql> create table `test1`(
`id` int not null auto_increment,
`username` varchar(45) not null,
`password` varchar(45) not null,
primary key(`id`)
);
mysql> drop table user0;
Query OK, 0 rows affected (0.01 sec)
ALTER TABLE `test`
ADD COLUMN `realname` VARCHAR(45) NULL AFTER `password`;
mysql> ALTER TABLE `test`
-> CHANGE COLUMN `realname` `zsxm` VARCHAR(45) NULL DEFAULT NULL ; Query OK, 0 rows affected (0.02 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> ALTER TABLE `test`
-> DROP COLUMN `zsxm`;
Query OK, 0 rows affected (0.01 sec)
Records: 0 Duplicates: 0 Warnings: 0
#insert into 表名 (字段名列表) values (字段值列表)
mysql> insert into test (id,username,password) values (3,'zhangsan','zhangsan');
Query OK, 1 row affected (0.01 sec)
mysql> insert into test(username,password)values('lisi','lisi');
Query OK, 1 row affected (0.00 sec)
delte from user where 条件;
mysql> delete from test where username='zhangsan';
Query OK, 1 row affected (0.00 sec)
mysql> insert into user values (1,'zhangsan','zhangsan');
Query OK, 1 row affected (0.00 sec)
mysql> update user set password=123 where username='zhangsan';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。