When mysql is used interactively, query results are presented in a table format. When used noninteractively, the result is presented in tab-separated format.The output format can be changed using command options. The simplest way to invoke mysql is to specify your MySQL username with the -u option, and to tell mysql to prompt you for your password with -p.
MySQL is considered the most popular database management system in the world. It is an open-source database management system which is usually installed as part of LAMP stack. For managing the data, it uses a relational database and structured query language (SQL). Here I am going to describe the steps of how to install MySQL on an Ubuntu server.
![Exit Exit](/uploads/1/2/5/4/125426182/790197244.jpg)
RequirementsBefore going to install MySQL on Ubuntu, it is advised to have the latest version of server with the necessary setup. This setup includes a non-root user having sudo privileges and a. Installation Process. MySQL InstallationIn the latest versions of Ubuntu, MySQL is available by default in the APT package repository. For a successful installation process, updating the package index on the server is essential with “apt.” sudo apt updateAfter that complete the installation of the default package. Sudo apt-get install mysql-serverBy this, MySQL will be installed. But, setting password and configuration modification is not allowed due to security purposes.
MySQL ConfiguringDuring a fresh installation, if you run the included security script, it will change some default options of less security for the purposes like sample users and remote root logins. In the latest versions of MySQL, the data directory is initialized automatically whereas older versions needed a manual initiation. Sudo mysqlsecureinstallationIt will drive you through a sequence where you can bring necessary changes to the security options of MySQL installation. The first prompt will inquire that whether you want to set up any password plugin to examine the strength of MySQL password given by you.
The second prompt will ask you to set up a password dedicated to the MySQL root user. Confirm the selected password from here.Then, pressing “ Y” and “ ENTER” will accept the defaults for all situations. Anonymous users and test database will be removed by this. This will also disable remote root login and activate the new rules changed by you for immediate action by MySQL.For initializing the MySQL data directory, use “ mysqlinstalldb” command for previous versions of 5.7.6 and for the versions after that use “ mysqld –initialize.” If MySQL is installed from the Debian distribution, data directory is initialized by default. No additional action required.It is to be mentioned that, setting a password for the root MySQL user does not ensure that the user has authentication with a password for connecting to MySQL shell. If required, following step 3 you can adjust this setting.
Adjustment of User Authentication and Privileges (Optional)No password but a default plugin “ authsocket” is used to authenticate the root MySQL user in Ubuntu systems running the latest versions of MySQL (5.7 and later). Though it permits for some greater security and ease of use, in some cases like allowing an external program to access the user, it may create a complicated scenario.For using a password to as root to MySQL, it is needed to change the authentication method. This change of authentication is form “ authsocket” to “ mysqlnativepassword.” From the terminal, open up MySQL prompt to perform this action.
Sudo mysqlAfter that, with the following command check the user authentication method of your MySQL user account. Mysql SELECT user,authenticationstring,plugin,host FROM mysql.user;In the above example, it is seen that using the “ authsocket” plugin; the root user complete the authentication process. For configuring the root account to authenticate using a password, the following “ ALTER USER” command is to run. Select a strong password and mind it that the root password set up in step 2 will be changed with this command. Mysql ALTER USER 'root'@'localhost' IDENTIFIED WITH mysqlnativepassword BY 'password';Then, run the following command to reload the grant tables and putting new changes into effect.
Mysql FLUSH PRIVILEGES;Check the authentication methods assigned by each user to be assured that root does not authenticate using “ authsocket” plugin. Mysql SELECT user,authenticationstring,plugin,host FROM mysql.user;In this example, you can see that the authentication is done by root MySQL user by using a password. Once confirmed on the server, you can exit the shell. Mysql exitNow, is the time to test the MySQL installation. Testing the MySQL InstallationNo matter how you have installed MySQL, it should have initiated functioning automatically. With the following command, check its status.
Sudo systemctl status mysql.serviceYou can initiate with: sudo systemctl start mysqlIf MySQL does not run. You can try in another way of connecting to the database utilizing “ mysqladmin” tool for an additional check. It is a client which allows run the administrative commands. Sudo mysqladmin -p -u root versionIt indicates that MySQL is up and running. Concluding WordsNow, MySQL is installed on your Ubuntu server. For ease of use, you can now modify it.
Besides, adding measures is also possible for enhancing security. Is this tutorial on how to install MySQL on Ubuntu helpful? If you like it, please take a moment to share this tutorial on your social network. And don’t forget to leave your suggestion and experience in the comment section.
![Mysql Mysql](/uploads/1/2/5/4/125426182/197343202.png)
PhpMyAdmin is a very useful web-based database management tool to manage MySQL or MariaDB databases. It is a free tool that is written in PHP. Different types of database tasks can be done easily by using this tool. PhpMyAdmin helps novice users to perform all types of basic database operations without having any knowledge of writing query. Some important features of this tool are mentioned below.
Create, drop, rename or alter databases, tables, columns, primary keys, unique keys and indexes. Insert, delete and update records of the tables. Manage server by applying various server configuration. Execute different types of simple and complex queries. Create, drop and modify stored procedures, triggers and views. Import or export database or table or data from or to different formats.To do web development works, you can install XAMPP or LAMP. If you are using XAMPP server for Ubuntu then you don’t need to install phpMyAdmin separately.
It will be installed on XAMPP server by default when you will install XAMPP server. But if you are using LAMP on Ubuntu then you have to install phpMyAdmin by downloading the package. This tutorial will help you to install phpMyAdmin on Ubuntu.Before starting the installation process, you must confirm that LAMP is working properly.
Run the following commands to check that Apache2, MySQL and PHP are installed and working.Check the current status of web server (Apache2). $ sudo apt install phpmyadmin php-mbstring php-gettextPress the space to select the server apache2, select Ok and press enter, when the following prompt appears.Select Yes and press enter to use dbconfig-common for setting up the database.Next, you have to set MySQL password to make connection with the database server by using phpMyAdmin.
Type the password, select Ok and press enter.Retype the password for confirmation. Select Ok and press enter.Run the following command to enable PHP extension, mbstring, for using phpMyAdmin Apache configuration file. $ sudo systemctl restart apache2Now, phpMyAdmin is installed properly and you can go for the next step to setup other configuration of phpMyAdmin. Step-2: Setup Authentication and PrivilegesA default username and password are set at the time of installing phpMyAdmin for doing database tasks.
The default username is ‘ phpmyadmin’ and the password is the one that you have set in the previous step. But it is better to use phpMyAdmin by making a connection as root user to perform all type of database operations. If no password is set for root user when MySQL or MariaDB server is installed then it is necessary to set a password for the database server later. Root user can use ‘ authsocket’ or ‘ mysqlnativepassword’ plugin to make connection with the server. If ‘ authsocket’ plugin is loaded for root user then change the authentication method of root user from ‘ authsocket’ to ‘ mysqlnativepassword’ for security purpose. You can also create new user account to access phpMyAdmin. Configuration for root User:Connect with the database server and check the current authentication method of root user.
exitAccess phpMyadmin from browser:Open any browser and type the following URL to check that phpMyAdmin is working properly or not.Now, login to the server by providing root or newly created user credentials. The following page will appear after login.Step-3: Using phpMyAdminThere are two panels in phpMyAdmin page. Left panel shows the list of all existing databases, tables, procedures and views. You have to click on ‘+’ button of the particular database to show the tables, procedures and views.Right panel contains different database server information and tab options to perform particular database tasks. Five sub panels of cPanel page are General settings, Appearance settings, Database server, Web server and phpMyAdmin.