安装MySQL_MySQL
安装MySQL
假设你把所有必须的源码或者包都放在了/tmp下。如果你下载的是RPM包的话,那比较简单;如果你下载的是二进制包(你没有rpm程序或者你想自定义的话),那么会稍微麻烦一点。
RPM包安装
你必须成为root用户才能使用rpm安装程序,以下是安装过程:
$ cd /tmp
$ su
# rpm -Uvh MySQL*(安装和MySQL相关的所有包)
这将安装你下载的所有3个MySQL包。如果你的系统是RedHat Linux的话,建议使用RPM安装方式,因为所有的工作都由rpm程序帮你搞好了。
源码安装
相对于用RPM安装来讲,用二进制源码安装是稍微麻烦了点。但是我们可以在安装脚本中可以自定义安装的相关参数,而不用象rpm方式只能安装默认的来安装。
安装二进制源代码
如果你下载的是二进制源代码,它的名字类似于: mysql-3.22.21-pc-linux-gnu-i686.tar.gz。你必须成为root用户,然后解压到 /usr/local目录,操作步骤如下:
$ cd /usr/local
$ su
# tar -zxvf /tmp/mysql-3.22.21-pc-linux-gnu-i686.tar.gz
在所有文件解压完后,一个名字叫mysql-3.22.21-pc-linux-gnu-i686的目录将被创建出来。mysql-3.22.21-pc-linux-gnu-i686这么长):
# ln -s mysql-3.22.21-pc-linux-gnu-i686 mysql
如果以后有新版本的MySQL的话,你可以仅仅将源码解压到新的路径,然后只需要做个符号链接就可以了。这样非常方便,数据也更加安全。
建立一个MySQL 用户
好,现在我们将建立一个能运行MySQL守护程序的用户帐号,并且所有MySQL文件都归此帐户拥有。使用 Linuxconf或者useradd命令去添加一个叫 mysql 的帐号,在添加之前,确保没有人注册了这个帐户,还要暂时禁止login功能(不过一般都是在没有其他人登陆的情况下调试机器,因此这个步骤可免)
为MySQL做准备
首先让我们将MySQL目录和文件的拥有权改成 mysql 用户和root组:
# cd /usr/local
# chown -R mysql:root mysql-3.22.21-pc-linux-gnu-i686 mysql
然后运行一个小脚本程序,以建立初始化的MySQL数据库。请以一个mysql 用户的身份完成这个任务,这也是我们能够直接使用这个帐户的唯一机会。
# su mysql
$ cd mysql
$ scripts/mysql_install_db
$ exit
如果没有任何出错信息显示的话,那就可以了。
自动运行MySQL
在MySQL二进制包里面,有一个叫myslq.server的启动脚本程序。把它复制到/etc/rc.d/init.d目录里面:
# cd /etc/rc.d/init.d
# cp /usr/local/mysql/support-files/mysql.server mysql
接着把它的属性改为“x”(executable,可执行)
# chmod +x mysql
最后,运行chkconfig把MySQL添加到你系统的启动服务组里面去。
# /sbin/chkconfig --del mysql
# /sbin/chkconfig --add mysql
测试MySQL
MySQL里面有一个简单的数据库例子test ,而且它的内部数据库一直保持对权限和帐户的监视,因而先运行mysql看看是否可以工作。
首先启动MySQL:
# /etc/rc.d/init.d/mysql start
如果一切正常,你将看到以下的信息出现:
Starting mysqld daemon with databases from /var/lib/mysql
如果你安装的是RPM包,那么程序大都安装在/usr/local/mysql/bin。在此目录下运行客户端程序:
# mysql
然后你可以看到屏幕显示出以下信息:
Welcome to the MySQL monitor. Commands end with ; or /g.
Your MySQL connection id is 2 to server version: 3.22.21
Type 'help' for help.
mysql>
接着,用show databases命令可以将安装的数据库列出来:
mysql> show databases;
你就可以看到:
+----------+
| Database |
+----------+
| mysql |
| test |
+----------+
2 rows in set (0.00 sec)
如果一切正常的话,那说明MySQL可以完全工作了!恭喜你!如果要退出程序,输入:exit
mysql> exit;
Bye
更改管理员密码
在一切正常后,要做的第一件事情是更改管理员的密码。你可以运行mysqladmin (请注意,此命令不一定在你的path中,所以最好是转到此命令的目录中直接执行):
# mysqladmin -u root password newpassword
此命令把root用户的口令变成newpassword。当然你可以把口令换成其它,因为这个很容易破解

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



With the rapid development of social media, Xiaohongshu has become one of the most popular social platforms. Users can create a Xiaohongshu account to show their personal identity and communicate and interact with other users. If you need to find a user’s Xiaohongshu number, you can follow these simple steps. 1. How to use Xiaohongshu account to find users? 1. Open the Xiaohongshu APP, click the "Discover" button in the lower right corner, and then select the "Notes" option. 2. In the note list, find the note posted by the user you want to find. Click to enter the note details page. 3. On the note details page, click the "Follow" button below the user's avatar to enter the user's personal homepage. 4. In the upper right corner of the user's personal homepage, click the three-dot button and select "Personal Information"

The Local Users and Groups utility is built into Computer Management and can be accessed from the console or independently. However, some users find that local users and groups are missing in Windows 11. For some people who have access to it, the message suggests that this snap-in may not work with this version of Windows 10. To manage user accounts for this computer, use the User Accounts tool in Control Panel. The issue has been reported in previous iterations of Windows 10 and is usually caused by issues or oversights on the user's side. Why are local users and groups missing in Windows 11? You are running Windows Home edition, local users and groups are available on Professional edition and above. Activity

In Ubuntu systems, the root user is usually disabled. To activate the root user, you can use the passwd command to set a password and then use the su- command to log in as root. The root user is a user with unrestricted system administrative rights. He has permissions to access and modify files, user management, software installation and removal, and system configuration changes. There are obvious differences between the root user and ordinary users. The root user has the highest authority and broader control rights in the system. The root user can execute important system commands and edit system files, which ordinary users cannot do. In this guide, I'll explore the Ubuntu root user, how to log in as root, and how it differs from a normal user. Notice

Certain folders are not always accessible due to permissions, and in today’s guide we will show you how to access user folders on your old hard drive on Windows 11. The process is simple but can take a while, sometimes even hours, depending on the size of the drive, so be extra patient and follow the instructions in this guide closely. Why can't I access my user folders on my old hard drive? User folders are owned by another computer, so you cannot modify them. You don't have any permissions on the folder other than ownership. How to open user files on old hard drive? 1. Take ownership of the folder and change permissions Find the old user directory, right-click on it and select Properties. Navigate to "An

Many users have been added to the Ubuntu system. I want to delete the users that are no longer in use. How to delete them? Let’s take a look at the detailed tutorial below. 1. Open the terminal command line and use the userdel command to delete the specified user. Be sure to add the sudo permission command, as shown in the figure below. 2. When deleting, be sure to be in the administrator directory. Ordinary users do not have this permission. , as shown in the figure below 3. After the delete command is executed, how to judge whether it has been truly deleted? Next we use the cat command to open the passwd file, as shown in the figure below 4. We see that the deleted user information is no longer in the passwd file, which proves that the user has been deleted, as shown in the figure below 5. Then we enter the home file

sudo (superuser execution) is a key command in Linux and Unix systems that allows ordinary users to run specific commands with root privileges. The function of sudo is mainly reflected in the following aspects: Providing permission control: sudo achieves strict control over system resources and sensitive operations by authorizing users to temporarily obtain superuser permissions. Ordinary users can only obtain temporary privileges through sudo when needed, and do not need to log in as superuser all the time. Improved security: By using sudo, you can avoid using the root account during routine operations. Using the root account for all operations may lead to unexpected system damage, as any mistaken or careless operation will have full permissions. and

Microsoft began rolling out KB2 to the public as an optional update for Windows 503145511H22 or later. This is the first update to enable Windows 11 Moment 4 features by default, including Windows Copilot in supported areas, preview support for items in the Start menu, ungrouping of the taskbar, and more. Additionally, it fixes several Windows 11 bugs, including potential performance issues that caused memory leaks. But ironically, the optional update for September 2023 will be a disaster for users trying to install the update, or even for those who have already installed it. Many users will not install this Wi

Analysis of user password storage mechanism in Linux system In Linux system, the storage of user password is one of the very important security mechanisms. This article will analyze the storage mechanism of user passwords in Linux systems, including the encrypted storage of passwords, the password verification process, and how to securely manage user passwords. At the same time, specific code examples will be used to demonstrate the actual operation process of password storage. 1. Encrypted storage of passwords In Linux systems, user passwords are not stored in the system in plain text, but are encrypted and stored. L
