Home Database Mysql Tutorial Ubuntu Linux 9.04 下MySQL安装与基本配置

Ubuntu Linux 9.04 下MySQL安装与基本配置

Jun 07, 2016 pm 04:55 PM
mysql installation ubuntu installation

今天第一次在Ubuntu Linux 9.04上安装 MySQL,之前也没安装过,所以参考了上些网络文章,进行了一些配置,以下是我安装的全过程一、

今天第一次在Ubuntu Linux 9.04上安装 MySQL,之前也没安装过,所以参考了上些网络文章,进行了一些配置,以下是我安装的全过程

一、安装和基本使用配置
我安装是直接使用 apt-get 进行安装,这也是我选择的安装方式,我的安装方法如下:
1、sudo apt-get install mysql-server --安装mysql服务端,我在9.04上安装时提示设置root密码,如果没有可以在安装好后进行更改设置,安装后的默认路径为: /etc/init.d/mysql
2、sudo apt-get install mysql-client --安装mysql客户端,用来操作mysql的CRUD操作,不过在9.04上安装服务端时以经安装好了客户端可以不需要安装,如果没有则安装
一旦安装完成,MySql服务器应该会自动启动,你可以在终端输入命令来查看是否启动:
chentao@amber-chentao:~$ sudo netstat -tap | grep mysql
当你执行该命令时可以看到如下信息
tcp 0 0 localhost:mysql *:* LISTEN 8368/mysqld
恭喜你,这说明mysql服务已启动,安装成功,如果不能启动可以通过下列命令来重新启动它
sudo /etc/init.d/mysql restart --restart

当确认mysql启动后 我们需要进行登录到mysql,这个时候可以在终端输入
chentao@amber-chentao:~$ mysql -uroot -p --执行Enter后提示输入root密码
Enter password:
当输入密码后就可进行对数据库操作了
那么如果你想设置mysql root 的密码可以通过下列命令
chentao@amber-chentao:~$ sudo mysqladmin -u root -oldpassword password newpassword

还有二种方式进入mysql终端后进行更改密码,就是进入mysql后,执行下列命令来更改当前用户密码
1、mysql>set password for root=password("root");
2、mysql> grant all privileges on *.* to root@localhost identified by "123456";

当所有的这些设置好了后我们可以来新建一个数据库,并添加一个用户来管理该数据库的CRUD操作
--创建一个名为 test 数据库
mysql> create database test;
--建立一个 test_root 的用户,他将对数据库 test 有CRUD的权限,以后管理数据库就可以用他来管理了,而不需要超级用户root
mysql> grant all privileges on test.* to test_root@localhost identified by "654321"
--我们看到上面的配置是一个限定死的,,test_root 用户只能对test数据库执行管理,有的时候我们不想只是限定在一个数据库,我们想让他对所有数据库都拥用CRUD的权限,那么执行下面命令
mysql> grant all privileges on *.* to test_root@localhost identified by "654321";
或者你也可以将 all privileges 改成 insert,update,delete,create,select,二种方式实现都是一样

mysql 有一个不好的地方就是,在安装好后只允许在本地进行访问,不允许通过远程访问主机,如果想设置某用户通过远程主机访问,这个时候需要设置mysql的配置,其体需要做二件事,如下:
1、mysql> grant all privileges on test_root@"%" identified by "654321"
2、chentao@amber-chentao:~$ sudo gedit /etc/mysql/my.cnf
在这里我使用了gedit文本编辑方式打开,当然你也可以使用 vi或vim 来执行编辑,在该文件中找到 bind-address = 127.0.0.1 的位置,将其更改为 bind-address=你本机的网络IP
这样设置就可以允许你的mysql使用其它机器访问了
至些你的mysql服务的基本配置就到些完成,下面是一些在网络上找的一些常用的mysql命令,附上以方便大家使用

/etc/init.d/mysql start --启动mysql
/etc/init.d/mysql restart --重新启动mysql
/etc/init.d/mysql shutdown --关闭mysql的命令
/etc/init.d/mysql stop --停止mysql 服务
chentao@amber-chentao:~$ mysql -uroot -p --登录mysql 服务器,在上面有讲解

下面还有关一些常用mysql内部操作提示符
show databases; -- 显示所有数据库列表
use test; --打开库
show tables; --查看找开数据库中所有数据表
describe tableName; -- 查询表结构
create table 表名(字段设定表); --创建表
create database 数据库名; --创建数据库
drop database 数据库名; --删除数据库
drop table tablename --删除表结构
delete from 表名; --删除表数据
select * from 表名; -- 查询指定表中所有数据

linux

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to do a personalized partition installation in Ubuntu 21.04? How to do a personalized partition installation in Ubuntu 21.04? Jan 02, 2024 pm 06:24 PM

Today I want to install the latest ubuntu21.04 system on one of my laptops, but this computer already has other operating systems and files, so I want to choose a custom free partition for installation, so that I don’t have to copy the files. Okay, how to implement it? Let’s take a look at the detailed tutorial below. First, we enter the installation interface of ubuntu21.04, select Simplified Chinese, and then choose to install Ubuntu. When it comes to the installation type window, we select the other options at the bottom and then select Continue at the bottom. Now we can customize the partition. Select a partition to install ubuntu and select the change. An edit partition window will pop up. The first size is the size of the partition, and the default is

MySQL can't be installed after downloading MySQL can't be installed after downloading Apr 08, 2025 am 11:24 AM

The main reasons for MySQL installation failure are: 1. Permission issues, you need to run as an administrator or use the sudo command; 2. Dependencies are missing, and you need to install relevant development packages; 3. Port conflicts, you need to close the program that occupies port 3306 or modify the configuration file; 4. The installation package is corrupt, you need to download and verify the integrity; 5. The environment variable is incorrectly configured, and the environment variables must be correctly configured according to the operating system. Solve these problems and carefully check each step to successfully install MySQL.

How to use mysql after installation How to use mysql after installation Apr 08, 2025 am 11:48 AM

The article introduces the operation of MySQL database. First, you need to install a MySQL client, such as MySQLWorkbench or command line client. 1. Use the mysql-uroot-p command to connect to the server and log in with the root account password; 2. Use CREATEDATABASE to create a database, and USE select a database; 3. Use CREATETABLE to create a table, define fields and data types; 4. Use INSERTINTO to insert data, query data, update data by UPDATE, and delete data by DELETE. Only by mastering these steps, learning to deal with common problems and optimizing database performance can you use MySQL efficiently.

How to solve the problem of missing dependencies when installing MySQL How to solve the problem of missing dependencies when installing MySQL Apr 08, 2025 pm 12:00 PM

MySQL installation failure is usually caused by the lack of dependencies. Solution: 1. Use system package manager (such as Linux apt, yum or dnf, Windows VisualC Redistributable) to install the missing dependency libraries, such as sudoaptinstalllibmysqlclient-dev; 2. Carefully check the error information and solve complex dependencies one by one; 3. Ensure that the package manager source is configured correctly and can access the network; 4. For Windows, download and install the necessary runtime libraries. Developing the habit of reading official documents and making good use of search engines can effectively solve problems.

How to fix the error in database file path setting during MySQL installation How to fix the error in database file path setting during MySQL installation Apr 08, 2025 am 11:12 AM

How to correct the error in MySQL database file path setting: 1. Stop MySQL service; 2. Strongly recommend backing up data; 3. Modify the datadir parameter in the configuration file to the correct path, and ensure that MySQL users have read and write permissions; 4. It is recommended to create a new data directory; 5. Start MySQL service; 6. Verify whether the database is running normally and data integrity. Be sure to operate with caution to avoid data loss.

MySQL installation error solution MySQL installation error solution Apr 08, 2025 am 10:48 AM

Common reasons and solutions for MySQL installation failure: 1. Incorrect username or password, or the MySQL service is not started, you need to check the username and password and start the service; 2. Port conflicts, you need to change the MySQL listening port or close the program that occupies port 3306; 3. The dependency library is missing, you need to use the system package manager to install the necessary dependency library; 4. Insufficient permissions, you need to use sudo or administrator rights to run the installer; 5. Incorrect configuration file, you need to check the my.cnf configuration file to ensure the configuration is correct. Only by working steadily and carefully checking can MySQL be installed smoothly.

How to solve the error of repeated installation when installing mysql How to solve the error of repeated installation when installing mysql Apr 08, 2025 am 10:39 AM

The solution to the MySQL repeated installation prompt is to completely remove the remaining traces: 1. Use the control panel to uninstall relevant programs; 2. Manually delete files and registry entries in the MySQL installation directory (backup before operation); 3. Stop and delete MySQL-related services in the system service; 4. Restart the computer. In addition, it is recommended to use professional uninstall tools, check environment variables, select official installation packages and clear installation paths to avoid this problem again.

MySQL installation failure reason MySQL installation failure reason Apr 08, 2025 am 10:51 AM

MySQL installation failure is usually caused by the following reasons: 1. Permission problems, requiring administrator or root permissions; 2. 3306 port conflicts, ports need to be checked and released or configuration modified; 3. The dependency library is missing, and it needs to be installed using the package manager; 4. The installation package is damaged, and it needs to be downloaded and verified; 5. The environment variable problem, the installation path needs to be configured correctly. The solution needs to be checked based on specific error information and operating system. For example, when installing source code under Linux, you can check the library file path and compilation options to ensure the installation process is completed smoothly.

See all articles