How to run sql commands in linux?

hello ,
I am new to linux In windows I used to install mysql application to run commands like create database->use database->create table…
How do I run these commands in linux for the output For my college work.
I have followed this guide and installed mariadb
https://forum.manjaro.org/t/howto-install-apache-mariadb-mysql-php-lamp/13000
I didn’t run the command sudo mysql_secure_installation.
Please help me :pray:

run command mysql as win

https://man.archlinux.org/man/mysql.1

or you want gui ? DBeaver,phpmyadmin,…

1 Like

I ran this command mysql db_student
And this was the output
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'db_student'

login not good for our db…

https://wiki.archlinux.org/title/MariaDB

I am a beginner and most of the things you shared are confusing to me :sweat: see I just want to run SQL commands like create table, alter table ,display table etc
I don’t want to host any server or anything I just want sql for my college assignments.
back In windows there was just this application mysql which I can open and start writing SQL queries.Is there any applications like that if there is how to download coz I can only find this mariadb for arch linux.
Hope you understand and help.

You can’t “just run” SQL commands. There must be a SQL server running somewhere that receives and executes your queries.

Which dialect are you planning to use? For SQLite, I recommend DB Browser for SQLite.

(pamac install sqlitebrowser)

Edit: Okay, if you need to use MySQL, you could use the MySQL Workbench

(pamac install mysql-workbench)

I know this is a bad windows habit but Should I download from here https://dev.mysql.com/downloads/mysql/
I want this one oracle one

No, use pamac to install mariadb (it is the same as MySQL) and the above-mentioned workbench for the queries.

okay I have installed mariadb as I told in the original post and now what do I need to do use my sql

Follow papajoke’s advise and read the instruction on the page that was linked (How to run sql commands in linux? - #4 by papajoke)

?

Anonymous Account (without login)
mysql/mariadb/oracle win/linux are servers ! so you need a login (root) and password.
Then it is possible to create users (with or without pass) and to give rights to these users on databases.

first, use root to access to your database, after we can select/create datables

mysql -u root -p

The guide I followed mentioned in the OP also had this secure installation I didn’t ran that.

mysql -u root -p
Enter password: pressed enter
ERROR 1698 (28000): Access denied for user ‘root’@‘localhost’

That’s why mysql_secure_installation is necessary. That’s enable root user and you can define his password. After that, mysql -u root -p and type the password you defined previously.

Once in mysql, you can create database db_student; and use db_student; and create tables etc etc.

1 Like

This wiki has always helped me. There really were a lot of solutions to similar questions.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.