Mysql创建数据库和独立数据库帐号方法介绍
本文章来给各位同学介绍phpMyadmin创建Mysql数据库及独立数据库帐号建立,如果你不会mysql命令来创建数据库之类的我们可以使用phpmyadmin来完成哦。
phpMyadmin创建Mysql数据库和独立数据库帐号教程
在一个服务器上一般来讲都不止一个站点,更不止一个MySQL(和PHP搭配之最佳组合)数据库。
为了防止安全隐患,我们一般针对每个数据库都设置了独立的数据库访问帐号,该帐号仅有访问该数据库的权限。下面就让我们来具体演示一下:
1、首先我们要登陆phpMyAdmin(做为现在的主流开发语言),不做演示。
2、创建一个数据库,如下图,在phpMyAdmin(做为现在的主流开发语言)右边窗口中,填写数据库名称,点创建即可。
例如我们这里创建一个名字为:cncmstest 的数据库
创建成功会有如下提示:
3、点击左上角的主页按钮,返回phpMyAdmin(做为现在的主流开发语言)主界面:
4、在主界面的右边点击“权限”来创建数据库帐号。
5、在权限页面中,我们点击“添加新用户”
6、在该页面中,我们填写要创建的数据库用户名,该用户的访问范围,及密码。
如上图,我们填写了用户名为:cncmsuser,该数据库用户只允许本机访问,主机一项选择本地;密码我们使用自动生成的,点下面的“Generate”会生成一个随机密码,然后点“Copy”会自动填写到密码框中。
下面的框都不选,直接拉到页面最下面点执行即可创建一个新用户。
数据库用户创建成功,会返回如下页面:
7、最重要的一步,设置该用户的数据库访问权限
在数据库用户添加成功返回的页面中可以直接设置权限。这里我们选择按数据库指定权限:
如上图,在数据库列表中选择我们刚刚创建的cncmstest,即会自动进入该数据库的权限设置页面。
在上图的权限设置中,我们把“数据”、“结构”两列的权限全部选中,管理权限都不要选。点执行即可。
到这里,我们已经全部设置完毕了,创建了一个数据库:cncmstest,并创建了数据库用户cncmsuser,特别指定了该用户只对cncmstest的访问权限。如此,便达到了我们一开始所讲的目的:为每一个数据库指定独立的用户访问权限。
下面简单介绍了下利用命令创建数据库
.新建用户。
代码如下 | 复制代码 |
//登录MYSQL @>mysql -u root -p @>密码 //创建用户 mysql> insert into mysql.user(Host,User,Password) values("localhost","phplamp",password("1234")); //刷新系统权限表 mysql>flush privileges; |
这样就创建了一个名为:phplamp 密码为:1234 的用户。
然后登录一下。
代码如下 | 复制代码 |
mysql>exit; |
2.为用户授权。
代码如下 | 复制代码 |
//登录MYSQL(有ROOT权限)。我里我以ROOT身份登录. /* |
3.删除用户。
代码如下 | 复制代码 |
@>mysql -u root -p @>密码 mysql>DELETE FROM user WHERE User="phplamp" and Host="localhost"; mysql>flush privileges; //删除用户的数据库 mysql>drop database phplampDB; |
4.修改指定用户密码。
代码如下 | 复制代码 |
@>mysql -u root -p @>密码 mysql>update mysql.user set password=password('新密码') where User="phplamp" and Host="localhost"; mysql>flush privileges; |
5.创建数据库
创建数据库
CREATE DATABASE 语句用于在 MySQL 中创建数据库。
语法
CREATE DATABASE database_name为了让 PHP 执行上面的语句,我们必须使用 mysql_query() 函数。此函数用于向 MySQL 连接发送查询或命令。
例子
在下面的例子中,我们创建了一个名为 "my_db" 的数据库:
代码如下 | 复制代码 |
$con = mysql_connect("localhost","peter","abc123"); if (mysql_query("CREATE DATABASE my_db",$con)) mysql_close($con); |

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



The main reasons why you cannot log in to MySQL as root are permission problems, configuration file errors, password inconsistent, socket file problems, or firewall interception. The solution includes: check whether the bind-address parameter in the configuration file is configured correctly. Check whether the root user permissions have been modified or deleted and reset. Verify that the password is accurate, including case and special characters. Check socket file permission settings and paths. Check that the firewall blocks connections to the MySQL server.

When MySQL modifys table structure, metadata locks are usually used, which may cause the table to be locked. To reduce the impact of locks, the following measures can be taken: 1. Keep tables available with online DDL; 2. Perform complex modifications in batches; 3. Operate during small or off-peak periods; 4. Use PT-OSC tools to achieve finer control.

In MySQL database, the relationship between the user and the database is defined by permissions and tables. The user has a username and password to access the database. Permissions are granted through the GRANT command, while the table is created by the CREATE TABLE command. To establish a relationship between a user and a database, you need to create a database, create a user, and then grant permissions.

1. Use the correct index to speed up data retrieval by reducing the amount of data scanned select*frommployeeswherelast_name='smith'; if you look up a column of a table multiple times, create an index for that column. If you or your app needs data from multiple columns according to the criteria, create a composite index 2. Avoid select * only those required columns, if you select all unwanted columns, this will only consume more server memory and cause the server to slow down at high load or frequency times For example, your table contains columns such as created_at and updated_at and timestamps, and then avoid selecting * because they do not require inefficient query se

MySQL cannot run directly on Android, but it can be implemented indirectly by using the following methods: using the lightweight database SQLite, which is built on the Android system, does not require a separate server, and has a small resource usage, which is very suitable for mobile device applications. Remotely connect to the MySQL server and connect to the MySQL database on the remote server through the network for data reading and writing, but there are disadvantages such as strong network dependencies, security issues and server costs.

MySQL has a free community version and a paid enterprise version. The community version can be used and modified for free, but the support is limited and is suitable for applications with low stability requirements and strong technical capabilities. The Enterprise Edition provides comprehensive commercial support for applications that require a stable, reliable, high-performance database and willing to pay for support. Factors considered when choosing a version include application criticality, budgeting, and technical skills. There is no perfect option, only the most suitable option, and you need to choose carefully according to the specific situation.

MySQL database performance optimization guide In resource-intensive applications, MySQL database plays a crucial role and is responsible for managing massive transactions. However, as the scale of application expands, database performance bottlenecks often become a constraint. This article will explore a series of effective MySQL performance optimization strategies to ensure that your application remains efficient and responsive under high loads. We will combine actual cases to explain in-depth key technologies such as indexing, query optimization, database design and caching. 1. Database architecture design and optimized database architecture is the cornerstone of MySQL performance optimization. Here are some core principles: Selecting the right data type and selecting the smallest data type that meets the needs can not only save storage space, but also improve data processing speed.

Data Integration Simplification: AmazonRDSMySQL and Redshift's zero ETL integration Efficient data integration is at the heart of a data-driven organization. Traditional ETL (extract, convert, load) processes are complex and time-consuming, especially when integrating databases (such as AmazonRDSMySQL) with data warehouses (such as Redshift). However, AWS provides zero ETL integration solutions that have completely changed this situation, providing a simplified, near-real-time solution for data migration from RDSMySQL to Redshift. This article will dive into RDSMySQL zero ETL integration with Redshift, explaining how it works and the advantages it brings to data engineers and developers.
