Mysql5.0学习笔记(一)_MySQL
1.登录
mysql -h localhost -u root
2.创建用户firstdb(密码firstdb)和数据库,并赋予权限于firstdb数据库
create database firstdb;
grant all on firstdb.* to firstdb identified by 'firstdb'
会自动创建用户firstdb
mysql默认的是本地主机是localhost,对应的IP地址就是127.0.0.1,所以你用你的IP地址登录会出错,如果你想用你的IP地址登录就要先进行授权用grant命令。
mysql>grant all on *.* to root@202.116.39.2 identified by "123456";
说明:grant 与on 之间是各种权限,例如:insert,select,update等
on 之后是数据库名和表名,第一个*表示所有的数据库,第二个*表示所有的表
root可以改成你的用户名,@后可以跟域名或IP地址,identified by 后面的是登录用的密码,可以省略,即缺省密码或者叫空密码。
drop database firstdb;
3.使用use 指定数据库
use firstdb;
select * from users;
注意:mysql命令以分号结束。
4.创建表
create table firstdb.users(id int, username varchar(40));
5.常用sql
show tables; 显示库中的表名
describe groups; 显示具体的表结构
insert into users(username) values('eking');
6.limit限制查询结果的数量(类似于sql server中的top)
SELECT * FROM users u limit 2; 返回前两条记录
SELECT * FROM users u order by id limit 1,1; 返回第2条记录(两个参数:偏移/限制行数)
分页:如果每页显示10条结果,第一页用limit 0,10 ;第二页用 limit 10, 10
7.Mysql5.0支持的字符集
MySQL中的字符集控制做得比较细,可以分为数据库级,表级, 字段级(这一点和ORACLE不同)。我上次改的字符集是数据库级的,对表sysuser没有影响,所以出现了改了字符集却一样无法插入中文的情况。
DROP TABLE IF EXISTS `firstdb`.`users`;
CREATE TABLE `firstdb`.`users` (
`id` int(11) NOT NULL auto_increment,
`username` varchar(40) default NULL,
`birthday` date default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=gb2312;
编译 MySQL 时,指定了一个默认的字符集,这个字符集是 latin1;
安装 MySQL 时,可以在配置文件 (my.ini) 中指定一个默认的的字符集,如果没指定,这个值继承自编译时指定的;
启动 mysqld 时,可以在命令行参数中指定一个默认的的字符集,如果没指定,这个值继承自配置文件中的;
此时 character_set_server 被设定为这个默认的字符集;
当创建一个新的数据库时,除非明确指定,这个数据库的字符集被缺省设定为 character_set_server;
当选定了一个数据库时,character_set_database 被设定为这个数据库默认的字符集;
在这个数据库里创建一张表时,表默认的字符集被设定为 character_set_database,也就是这个数据库默认的字符集;
当在表内设置一栏时,除非明确指定,否则此栏缺省的字符集就是表默认的字符集;
这个字符集就是数据库中实际存储数据采用的字符集,mysqldump 出来的内容就是这个字符集下的;
Query Browser1.1 对中文输入的支持太差劲了,可以用notebook写好后,再copy过去执行
update firstdb.users set username='以' where id=3;

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

When using Win11 system, sometimes you will encounter a prompt that requires you to enter the administrator username and password. This article will discuss how to deal with this situation. Method 1: 1. Click [Windows Logo], then press [Shift+Restart] to enter safe mode; or enter safe mode this way: click the Start menu and select Settings. Select "Update and Security"; select "Restart Now" in "Recovery"; after restarting and entering the options, select - Troubleshoot - Advanced Options - Startup Settings -&mdash

Wireless networks have become an indispensable part of people's lives in today's digital world. Protecting the security of personal wireless networks is particularly important, however. Setting a strong password is key to ensuring that your WiFi network cannot be hacked by others. To ensure your network security, this article will introduce in detail how to use your mobile phone to change the router WiFi password. 1. Open the router management page - Open the router management page in the mobile browser and enter the router's default IP address. 2. Enter the administrator username and password - To gain access, enter the correct administrator username and password in the login page. 3. Navigate to the wireless settings page - find and click to enter the wireless settings page, in the router management page. 4. Find the current Wi

Wireless networks have become an indispensable part of our lives with the rapid development of the Internet. In order to protect personal information and network security, it is very important to change your wifi password regularly, however. To help you better protect your home network security, this article will introduce you to a detailed tutorial on how to use your mobile phone to change your WiFi password. 1. Understand the importance of WiFi passwords. WiFi passwords are the first line of defense to protect personal information and network security. In the Internet age, understanding its importance can better understand why passwords need to be changed regularly. 2. Confirm that the phone is connected to wifi. First, make sure that the phone is connected to the wifi network whose password you want to change before changing the wifi password. 3. Open the phone’s settings menu and enter the phone’s settings menu.

1. Download and install Xiaobai’s one-click system reinstallation tool on another computer, insert an empty USB disk to create a USB boot disk. For specific tutorials, please refer to: 2. Insert the USB boot disk into the computer that needs to change the password to restart, and press Start hotkey. Generally, the startup hotkey is one of F12, F8, F9, F10, and ESC. Then the startup interface appears, select the option of the USB disk and press Enter to enter. 3. Select [1] to start win10x64PE and press Enter to confirm. 4. Select the password modification tool on the desktop and double-click to open it. 5. Then a list of account names appears, select the account that needs to change the password and open it. 6. Click the Change Password command below, enter the new password twice, and then click OK to save the changes. 7. Finally, unplug the USB flash drive and restart the computer. Then it will be normal.

Wireless networks have become an integral part of people's lives in modern society. Or need to view saved passwords in WiFi list, sometimes we forget WiFi password, however. Mobile software came into being to solve this problem. To make it easy for you to master this magical tool, this article will introduce a software that can help you quickly unlock all WiFi passwords. 1. Powerful WiFi password unlocking tool - explore the wonderful world of WiFi password unlocking 2. Simple and easy-to-use interface design - convenient and fast operation methods 3. Supports multiple devices - meets the needs of different devices 4. Automatically Update - always keep the latest WiFi password 5. High-speed WiFi connection - easily cope with the simultaneous connection needs of multiple devices

Go language is an efficient, concise and easy-to-learn programming language. It is favored by developers because of its advantages in concurrent programming and network programming. In actual development, database operations are an indispensable part. This article will introduce how to use Go language to implement database addition, deletion, modification and query operations. In Go language, we usually use third-party libraries to operate databases, such as commonly used sql packages, gorm, etc. Here we take the sql package as an example to introduce how to implement the addition, deletion, modification and query operations of the database. Assume we are using a MySQL database.

Our mobile phones have become an integral part of our lives in modern society. Wireless network connections have also become an indispensable tool in our daily lives. However, sometimes we face such a situation: we want to connect to other devices but are unable to do so, we connect to WiFi but forget the password. How to easily get the WiFi password of a connected mobile phone? Find the saved WiFi password on the phone 1. Find the "WiFi" option in the settings, find and click it, and enter the phone's settings interface "WiFi" to enter the WiFi settings page, option. 2. Open the connected WiFi network details, find the name of the connected WiFi network, click to enter the detailed information page of the network, in the WiFi settings page. 3.

In the Windows 10 system, the password policy is a set of security rules to ensure that the passwords set by users meet certain strength and complexity requirements. If the system prompts that your password does not meet the password policy requirements, it usually means that your password does not meet the requirements set by Microsoft. standards for complexity, length, or character types, so how can this be avoided? Users can directly find the password policy under the local computer policy to perform operations. Let’s take a look below. Solutions that do not comply with password policy specifications: Change the password length: According to the password policy requirements, we can try to increase the length of the password, such as changing the original 6-digit password to 8-digit or longer. Add special characters: Password policies often require special characters such as @, #, $, etc. I
