This instructable will show you how to create a message board website using php, mysql, html, and css. If you are new to web development, do not worry, there will be detailed explanations and analogies so you may better understand the concepts.Materials Needed:. Text editor (i.e Sublime Text, Atom, etc). I will be using sublime text. WAMP stands for Windows Apache MySQL and PHP. MAMP stands for Mac Apache MySQL and PHPMAMP for Mac users: (includes MySQL and PHP)WAMP for Windows users: (includes MySQL and PHP)Sublime Text.
- Mysql Create Database And User
- Grant All Privileges On Wordpress.* To 'user'@'localhost' Identified By 'password'
- Grant All Privileges Mysql
The way to keep track of messages is to store them in a database. In this tutorial, we will be using MySQL. (I am using WAMP since I have a windows based operating system). Configure PHP and MySQL by making sure they are downloaded and you can navigate to their file location on your computer.
Open command prompt and navigate to your mysql directory and type 'mysqladmin -u root -p password.' This command will ask for your password and for you to enter it again. Now start your WAMP or MAMP server. There will appear a green icon once the server finished loading. Click the icon - MySQL - MySQL console to make sure you can login in with your newly created password.
Now the task is to create the database where the information about the messages will be stored. Let's think about what is usually needed from a message. Common items included: Name, the time the message was posted,time the message was posted, and the message itself.

Granting all privileges only affects the given privilege level. For example, granting all privileges on a table does not grant any privileges on the database or globally. Using ALL PRIVILEGES does not grant the special GRANT OPTION privilege. You can use ALL instead of ALL PRIVILEGES. The GRANT OPTION Privilege.
Create database named 'message'. Create table named 'comments' and add the rows: id (Integer type that auto increments), name (Varchar type), comment(Varchar type), time (Varchar type), date(Varchar type),. Connect to the 'message' database in a php file name 'db.php'.
- In GRANT statements, the ALL PRIVILEGES or PROXY privilege must be named by itself and cannot be specified along with other privileges. ALL PRIVILEGES stands for all privileges available for the level at which privileges are to be granted except for the GRANT OPTION and PROXY privileges.
- I often see in many MySQL tutorials that people use command IDENTIFIED BY 'password' both during user creation and granting him privileges. For example: CREATE USER 'username'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON database.

Create the input field for the author's name and text area for the message. Validate the data before inserting it into the database. If everything is fine, insert the message, name of author, date and time the post was posted. Display the messages by retrieving all databases records into a html div and style the page using CSS. Horray, you have successfully learned to create a messaging system.
Picture 1 - Once the database is created, you may enter the command 'show databases' to make sure the database was created successfully. SHOW DATABASES;Picture 2 - In order to store information in the database a table needs to be created. Creating the table with the essential rows is key to making sure the website has all necessary information.The table comments will have all the necessary informationIn order to be able to connect to the message database, issue the 'GRANT ALL PRIVILEGES ON message.' command. You may use your own username and password, just please do not forget it. CREATE DATABASE message; GRANT ALL PRIVILEGES ON message.TO 'username'@'localhost'IDENTIFIED BY 'password';Picture 3 - Enter 'describe comments' to make sure that the table was created successfully. You can see the rows and their data types by issuing this command.
DESCRIBE COMMENTS;Picture 4 - Since the row for the comment was not originally there, let's add it with the ALTER TABLE command. The comment is type VARCHAR(255) this means that the comment will be text that cannot exceed a length of 255 characters.
ALTER TABLE message ADD COLUMN comments VARCHAR(255) NOT NULL;The 255 represents the max length for comment. Not null means that when a message is inserted into the database, the comment field in the database can not be empty (null; non-existent). The db.php (db short for database) uses the username and password I used once the database was created when I issued the 'GRANT ALL PRIVILEGES' command.The define function at the top of the file indicates that the variables DBSERVER, DBUSER, DBPASSWORD, DBNAME are constants (they don't change in value). The if statements checks if the connection to the database failed or not.2. In the index.php file, we will use php's require function to connect the page to the database.
Mysql Create Database And User
Next, create a input field for the name. Then make the textarea for the message. Once these are created visit (you may not have a port number i.e 8080) to make sure you see the input box and textarea.3. Next, let's gather the form data and then insert into the database.4.
Now, let's add query the database and output all messages into a div.5. To style things a bit better, let's add some CSS to make it a little prettier.PS: I had a typo. Please change 'message' to comment near the INSERT command for the $query variable.
GRANT ALL PRIVILEGES ON mydb. TO 'myuser'@'%' WITH GRANT OPTION; WITH GRANT OPTION@Romain Users setting up an MySQL server are likely intelligent enough to realise that they should replace myuser with their own custom username.@Romain you are not really bringing alot to the table here - i don't name my users myuser - the questioner was simply using a username as an example - i used the same example username for consistency.Fair enough.
But one has to also think about the other people, possibly newbies, that could come read this question later on. Isn't it the point of SO as well?For security reasons, you should not use this type of user account for any process that the public will have access to (i.e. It is recommended that you create a user with only database privileges for that kind of use.I also don't think this answer is the good one.
It gives 'administrator' privileges on all databases and all tables, which is not what was asked.I edited this answer to say mydb. instead of., since it's such a widely upvoted and viewed answer, and I believe security-especially with a polished turd like MySQL-is extremely important. One would hope that a reader would investigate the details of the answer rather than copy and paste, but I like to live in reality occasionally.The GRANT OPTION privilege enables you to give to other users or remove from other users those privileges that you yourself possess.Note. Grant all privileges on mydb. to myuser@'%' identified by 'mypasswd';grant all privileges on mydb. to myuser@localhost identified by 'mypasswd';% seems to not cover socket communications, that the localhost is for. WITH GRANT OPTION is only good for the super user, otherwise it is usually a security risk.+1 for not including WITH GRANT OPTION and targeting a specified database instead of all (.).@EvanDonovan, there are a lot of things here that depend on use case as well environment.
Grant All Privileges On Wordpress.* To 'user'@'localhost' Identified By 'password'
For example java driver does not support socket transport at all IIRC. But generally I agree - better specify specific IPs when possible, or run server only on 127.0.0.1 and firewall the server when listening to non-localhost.@IanBussieres the grammar of '% seems to not cover socket communications, that the localhost is for' is unclear. What does this actually mean?@Thufir, search for unix sockets. When using localhost myslq client on linux is trying to use a unix socket instead of a TCP connection to the server.Note that you probably don't need the first command unless you want access from outside IP addresses, or from other computers on the local subnet.
If you do, I would recommend using commands that are targeted to the specific IP addresses that you want to allow, such as myuser@192.168.0.1 (for one on the local subnet), rather than myuser@% generally.This is old question but I don't think the accepted answer is safe. It's good for creating a super user but not good if you want to grant privileges on a single database.Note. CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password'; FLUSH PRIVILEGES; GRANT ALL PRIVILEGES ON.
Grant All Privileges Mysql
TO 'newuser'@'localhost';Either you wholesale copied from Linode, or they copied from you: linode.com/docs/databases/mysql/If you are not comfortable with the command line then you can use a client like MySQL workbench, Navicat or SQLyogOnce you have finalized the permissions that you want to set up for your new users, always be sure to reload all the privileges.Sadly, at this point newuser has no permissions to do anything with the databases. In fact, if newuser even tries to login (with the password, password), they will not be able to reach the MySQL shell.The asterisks in this command refer to the database and table (respectively) that they can accessthis specific command allows to the user to read, edit, execute and perform all tasks across all the databases and tables.Therefore, the first thing to do is to provide the user with access to the information they will need.Your changes will now be in effect.flush privileges is not needed when you use grant commands. FLUSH PRIVILEGES; GRANT EXECUTE, PROCESS, SELECT, SHOW DATABASES, SHOW VIEW, ALTER, ALTER ROUTINE,CREATE, CREATE ROUTINE, CREATE TEMPORARY TABLES, CREATE VIEW, DELETE, DROP,EVENT, INDEX, INSERT, REFERENCES, TRIGGER, UPDATE, CREATE USER, FILE,LOCK TABLES, RELOAD, REPLICATION CLIENT, REPLICATION SLAVE, SHUTDOWN,SUPERON. TO mysql@'%'WITH GRANT OPTION;Hello I used this code to have the super user in mysqlNote: The exact list in the GRANT varies between Versions of MySQL.and thenflush privileges is not needed when you use grant commands.