mysql数据库基本操作三_MySQL
环境:msyql版本5.0,windows操作系统
mysqladmin命令修改密码
034039->123456
C:/Users/ASUS>mysqladmin -u root -p034039 password 123456C:/Users/ASUS>mysql -u root -p123456Welcome to the MySQL monitor. Commands end with ; or /g.Your MySQL connection id is 32Server version: 5.0.96-community-nt MySQL Community Edition (GPL)Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.mysql>
大坑:
这条语句C:/Users/ASUS>mysqladmin -u root -p123456 password '034039';
其实新的密码为'034039';
也就是说单引号被解释为密码的一部分
你说坑不坑
C:/Users/ASUS>mysqladmin -u root -p123456 password '034039';C:/Users/ASUS>mysql -u root -p'034039'ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)C:/Users/ASUS>mysql -u root -p'034039';Welcome to the MySQL monitor. Commands end with ; or /g.Your MySQL connection id is 35Server version: 5.0.96-community-nt MySQL Community Edition (GPL)Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.mysql>
类似的有
C:/Users/ASUS>mysqladmin -u root -p'034039'; password "123456"C:/Users/ASUS>mysql -u root -p"123456"Welcome to the MySQL monitor. Commands end with ; or /g.Your MySQL connection id is 37Server version: 5.0.96-community-nt MySQL Community Edition (GPL)Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.mysql> Ctrl-C -- exit!Bye
现在mysql的密码是什么?其实是123456,不带双引号
则:
C:/Users/ASUS>mysqladmin -u root -p034039 password "123456"C:/Users/ASUS>mysql -u root -p123456Welcome to the MySQL monitor. Commands end with ; or /g.Your MySQL connection id is 44Server version: 5.0.96-community-nt MySQL Community Edition (GPL)Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.mysql>Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '/h' for help. Type '/c' to clear the current input statemenmysql>
也就是说在Windows中,一定要使用双引号,双引号不会被解释为密码的一部分。当密码中有空格时,要使用双引号
如果密码输错了就会出现这样的错误:
C:/Users/ASUS>mysql -u root -p123ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
mysql忘记密码
停止mysql服务
D:/>net stop mysqlMySQL 服务正在停止.MySQL 服务已成功停止。
打开mysql的配置文件my.ini
在[mysqld]下加入该条语句
skip-grant-tables
保存退出
然后重新启动mysql
D:/>net start mysqlMySQL 服务正在启动 .MySQL 服务已经启动成功。
登录mysql,不使用密码可以直接登录
D:/>mysql -h localhost -u root -pEnter password:Welcome to the MySQL monitor. Commands end with ; or /g.Your MySQL connection id is 1Server version: 5.0.96-community-nt MySQL Community Edition (GPL)Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.mysql>
执行下面命令
mysql> use mysql;Database changedmysql> update user set password = password("123456") where user = "root";Query OK, 2 rows affected (0.06 sec)Rows matched: 2 Changed: 2 Warnings: 0mysql> flush privileges;Query OK, 0 rows affected (0.01 sec)mysql> exitBye
现在设置了登录密码为123456。应该删除skip-grant-tables这条语句,然后重新启动,现在就可以使用新密码登陆了。

Alat AI Hot

Undresser.AI Undress
Apl berkuasa AI untuk mencipta foto bogel yang realistik

AI Clothes Remover
Alat AI dalam talian untuk mengeluarkan pakaian daripada foto.

Undress AI Tool
Gambar buka pakaian secara percuma

Clothoff.io
Penyingkiran pakaian AI

AI Hentai Generator
Menjana ai hentai secara percuma.

Artikel Panas

Alat panas

Notepad++7.3.1
Editor kod yang mudah digunakan dan percuma

SublimeText3 versi Cina
Versi Cina, sangat mudah digunakan

Hantar Studio 13.0.1
Persekitaran pembangunan bersepadu PHP yang berkuasa

Dreamweaver CS6
Alat pembangunan web visual

SublimeText3 versi Mac
Perisian penyuntingan kod peringkat Tuhan (SublimeText3)

Topik panas

Artikel ini membincangkan menggunakan pernyataan jadual Alter MySQL untuk mengubah suai jadual, termasuk menambah/menjatuhkan lajur, menamakan semula jadual/lajur, dan menukar jenis data lajur.

Artikel membincangkan mengkonfigurasi penyulitan SSL/TLS untuk MySQL, termasuk penjanaan sijil dan pengesahan. Isu utama menggunakan implikasi keselamatan sijil yang ditandatangani sendiri. [Kira-kira aksara: 159]

Artikel membincangkan strategi untuk mengendalikan dataset besar di MySQL, termasuk pembahagian, sharding, pengindeksan, dan pengoptimuman pertanyaan.

Artikel membincangkan alat MySQL GUI yang popular seperti MySQL Workbench dan PHPMyAdmin, membandingkan ciri dan kesesuaian mereka untuk pemula dan pengguna maju. [159 aksara]

Artikel ini membincangkan jadual menjatuhkan di MySQL menggunakan pernyataan Jadual Drop, menekankan langkah berjaga -jaga dan risiko. Ia menyoroti bahawa tindakan itu tidak dapat dipulihkan tanpa sandaran, memperincikan kaedah pemulihan dan bahaya persekitaran pengeluaran yang berpotensi.

Artikel ini membincangkan membuat indeks pada lajur JSON dalam pelbagai pangkalan data seperti PostgreSQL, MySQL, dan MongoDB untuk meningkatkan prestasi pertanyaan. Ia menerangkan sintaks dan faedah mengindeks laluan JSON tertentu, dan menyenaraikan sistem pangkalan data yang disokong.

Artikel membincangkan menggunakan kunci asing untuk mewakili hubungan dalam pangkalan data, memberi tumpuan kepada amalan terbaik, integriti data, dan perangkap umum untuk dielakkan.

Artikel membincangkan mendapatkan MySQL terhadap suntikan SQL dan serangan kekerasan menggunakan pernyataan yang disediakan, pengesahan input, dan dasar kata laluan yang kuat. (159 aksara)
