bitsCN.com
在linux下面安装MySQL5.6管理帐号安装失败的解决方法
这不算什么文章,只是为了记录今天下午我无缘无故花费的时间。避免下次浪费同样的时间,我还是把今天遇到的问题和解决方法记录下来吧。
MySQL其实并不复杂,但自从某一个版本开始,MySQL的安装变得越来越复杂。不明白他们为什么这么做,是因为被oracle收购的原因么?
我用的是redhat,安装的MySQL版本5.6。安装文件为rpm包。简单说一下正常的MySQL rpm包的安装流程:
redhat一般会自带一个mysql,首先要卸载它,否则安装会冲突。
如果有yum,可以运行
1
>yum list mysql-client
2
>yum list mysql-server
来找出安装的mysql。
运行
1
>yum remove package-name
来删除mysql的包。
如果没有yum,可以使用
1
>rpm -qal | grep mysql
列出已经安装的rpm,使用
1
>rpm -e package-name
来删除。
最后运行命令
1
>whereis mysql
来查看还有没有mysql的目录,使用rm命令删除所有遗留目录。
使用
1
>rpm -ivh mysql-package-name
来安装Mysql。 一般情况必须装的两个包是mysql-server和mysql-client。 mysql-client提供了mysql和mysqladmin等查询和管理工具。
rpm安装会自动调用mysql_install_db命令,为我们populate数据库用户表。这张表存在数据库mysql中,名字叫user. rpm安装会自动为你创建root用户,并随即产生一个密码,密码存放在/root/.mysql_secret中。
接下来就是启动mysql server, 可以使用以下几种命令:
1
>mysqld -u mysql
2
>/etc/init.d/mysql start
需要使用root来连接数据库,或者使用mysqladmin来管理帐户。然后重设你的密码。并创建其他用户。每个用户会有多种登陆方式,remote, localhost等等。你需要为你的帐户制定各种登陆方式以及相应的密码。
至此,你的mysql就配置完成了。
接下来说我遇到的问题。这个问题费了我不少时间。
当我做完上面的第4步以后,执行第5步,发现我无论用什么帐户,都无法登陆到mysql中去,使用mysqladmin也必须用root登陆。所以我的root是一个无效存在。/root/.mysql_secret里面的密码倒是存在。这说明,rpm安装过程中,mysql_install_db出现了问题,可能是bug。我卸载了重装,也无法解决问题。于是乎,我只能启动Mysql的安全模式,去查看user表里面到底有没有用户。
启动mysql安全模式。
1
停止mysql :
2
>/etc/init.d/mysql stop
3
4
启动安全模式:
5
>mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
连接mysql。以上的模式下,mysql不会检查用户密码。你可以直接运行mysql就能连接。
查看user表。运行
1
mysql>use mysql;
2
mysql>select * from user;
我发现这张表里面没有任何数据。这验证了我之前的想法,用户并没有被populate进来。怎么办?只能自己给它创建一个用户了。
创建root用户:
1
mysql>INSERT INTO user VALUES('localhost','root',password('root'),
2
'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y',
3
'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y',
4
'Y','Y','Y','Y','Y','','','','','0','0','0','0','','','N');
分别要注意4个值,第一行的3个,和最后一行的最后一个值。第一行3个分别是用户的方法方式,%代表任意host,也可以使用ip。最后一个值"N",代表你的password是否过期,如果过期,你在登陆的时候你需要重设密码。
至此,你有了一个root帐号。关闭安全模式,启动正常模式,用root登陆进mysql, 接下来你就回归正常的流程的第7步了。
完毕。
bitsCN.com

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA


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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

Dreamweaver CS6
Visual web development tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Chinese version
Chinese version, very easy to use

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.